keystatic icon indicating copy to clipboard operation
keystatic copied to clipboard

Give more freedom to customise the preview url

Open emilienbidet opened this issue 1 year ago • 0 comments

Hello Keystatic team!

I'm using Keystatic with Astro for building a news website. I feel it's very boring to copy / paste the slug of my article to view the result.

I can't use previewUrl stuff that @emmatown built because the final url of my blog post are depending on a field value of the entry (here is the category: news, bourse, bank...).

Could it be more friendly to have a function for previewUrl with the {value} as props and we return the pathname of the final url of the entry ?

Something like this :

    posts: collection({
      label: "Posts",
      slugField: "title",
      path: "src/content/posts/**",
      entryLayout: "content",
      previewUrl: ({value}) => `/${entry.category}/${entry.slug}`,
      schema: {
        ...
        category: fields.select({
          label: "Category",
          options: categorySelectOptions,
          defaultValue: categorySelectOptions[0].value,
        }),
        ...

Thank you and have a good day

emilienbidet avatar Mar 17 '24 14:03 emilienbidet