Repository navigation
Replies: 1 comment 1 reply
|
Hi Aaron, thanks for sharing! Not against this, but it feels more like a band-aid rather than addressing the underlying issue or need. Could you share more about your use case, like why do these entries need to have different paths? Is there some pattern or grouping going on? |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
The problem
A collection's
urlPatternis the only way EmDash knows an entry's public URL, and it can only be filled with{slug},{id}and date tokens. Sites migrated from WordPress often keep URLs that no single pattern expresses. In our case:/solutions/<area>/<page>/,/integrations/<page>/,/products/<page>/,/comparison/<page>/;/privacy-policy/,/security/...);So we store each entry's URL in a
pathfield, and our routes build the page there. EmDash doesn't know about that field, so every admin link to such an entry points at the pattern's URL, which 404s:resolveHref), which writes that wrong URL into other entries' content, so the broken link gets stored, not just displayed.Splitting collections by URL prefix doesn't help: the one-off paths still have no pattern, and a collection is a content shape, not a URL family. There's no plugin hook, config option or field role to override one entry's URL (
getPublicUrlreads the pattern and can't be changed).Proposal
A collection-level setting naming the field that holds an entry's own URL, e.g. in the seed or the content type editor:
{ "slug": "landing", "urlPattern": "/lp/{slug}/", "urlField": "path" }When the entry's
urlFieldvalue is a safe site-relative path (one leading/, no backslash or control characters), it replaces the pattern; otherwise the pattern applies as today. Places that would honour it:contentUrland its callers (View live, list icon, calendar, preview fallback, link picker);interpolateUrlPatternconsumers (getPublicUrl, the preview-url route, sitemaps, hreflang, menus' content items). The link picker would need the entry's data (it already fetches the entry for date-token patterns).Slug-change auto-redirects could skip entries whose URL comes from the field, since their URL doesn't change with the slug.
A related gap: the admin on its own host
Our admin runs on a separate host from the public site (behind Cloudflare Access), and the site is static. The admin's links are site-relative, so even a correct path opens on the admin's host. It would help if links that open a page (not the link picker's, which should stay relative) used the origin of the Site URL setting, as canonical URLs and sitemaps already do in 1.2.
What we do today
We run both as a small local patch on
@emdash-cms/admin@1.1.0:contentUrltakes an optionalpathfrom a fixedpathfield, and page-opening links are prefixed with the Site URL's origin. We'd much rather drop the patch for a supported setting, and we're happy to contribute a PR if this direction is acceptable.Related: #687 (URL pattern design alternatives), #2554 and #3366 (reading an entry's public URL), #2975 and #1099 (templates missing a
urlPattern).Drafted with Claude (Claude Opus 5.5) - hope this is okay!
All reactions