URL Pattern Configuration: Design Alternatives for Published Content Links #687
Replies: 2 comments 1 reply
-
|
Adding a fifth option to A–D, in case it's useful framing: Option E — opt-in catch-all route driven by
An additive integration option would close that loop: emdash({
contentRoutes: { entrypoint: "./src/layouts/EmDashEntry.astro" },
})When set, the integration injects a catch-all route that calls Relative to A–D this is complementary rather than competing:
Happy to prototype this for review if the direction is interesting. Filed an issue at #728 before noticing this Discussion — closing that and pointing it here. |
Beta Was this translation helpful? Give feedback.
-
|
I don't want to fight the Astro router on this. I'm open to the idea of a catch-all for default rendering, but I'm not sure this approach is right. What does it offer that adding |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Overview
I've noticed an inconsistency in how published content URLs are generated across starter templates. The
contentUrl()function in the admin generates URLs based on collection names and optionalurlPatternconfiguration, but there's a disconnect between these generated URLs and actual Astro routes in the templates.Examples of the Issue
/projects/{slug}, but the Astro route is at/work/{slug}/pages/about, but the Astro route is at/aboutThis results in 404s when users click the "View Published" link in the admin dashboard.
Root Cause
The
contentUrl()function (inpackages/admin/src/lib/url.ts) has three modes:urlPatternis provided → use it (e.g.,/blog/{slug})/{collection}/{slug}The starter templates don't consistently configure
urlPatternfor each collection, leading to mismatches.Questions for the Maintainers
Before I submit a fix, I'd like to understand the intended design:
Should
urlPatternbe required/validated? Should the system warn users when a collection doesn't have a configured URL pattern?Should URL mapping be centralized? Would it be better to:
Should starter templates auto-configure this? Should
urlPatternbe pre-configured in starter templates to match their actual routes?Should there be a fallback mechanism? If a URL pattern is missing, should the admin:
Proposed Solutions
I'm considering these approaches:
urlPatternfor each collection + improve docsurlPatternis missingNext Steps
Which approach aligns best with your vision for emdash? I'm happy to implement whichever solution the team prefers.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions