Thinkmill / Thinkmill/keystatic

Give more freedom to customise the preview url

Open
#1,024 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
2.4k
Forks
159
Avg merge
21h 41m
Merged PRs (30d)
2

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing previewUrl support for collections and the collection configuration shown in the issue. Determine how a preview callback could receive the entry value and return a pathname based on fields such as category and slug; done means a collection can configure that callback and generate the requested final URL.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
content, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.