Thinkmill / Thinkmill/keystatic

[Question] How can I implement a redirect editor deduplicated by fromUrl?

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

Nobody has claimed this yet.

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

Description

Background

I wanted to enable configuring URL redirects, e.g.

  • /very-long-path -> /vlp
  • /deprecated-page -> /

I was able to create a configuration page by either collections or a singleton with array of object(fromUrl, toUrl) field.

Problem

However, I was not able to find a way to deduplicate by fromUrl field. E.g.

  • /very-long-path -> /vlp
  • /deprecated-page -> /
  • /very-long-path -> / (Adding this does not make sense, as it conflicts with the first config. But it is allowed from the UI)

My question is: How do I deduplicate my collections or array items with a specific field value?
When there are more entries it's hard to find duplicates so it's better to have a programatic way.
My current workaround is to run a ci check for duplications, but it's better if we know that when we are editing it.

Possible solutions

  • Validation function across array items
  • A fields.map type that allows user enter key and value, and key must be unique.

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 reviewing the existing collection, singleton, array, and fields.map configuration APIs referenced in the issue. Determine whether validation can inspect sibling items and enforce unique fromUrl values, or whether a keyed field type is needed. Done means identifying a supported approach or clearly scoping the required editor and validation change.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
content
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.