Replies: 2 comments 1 reply
-
|
How would this be used in a template? |
Beta Was this translation helpful? Give feedback.
-
|
Good question — and it points at a real gap. Today EmDash templates own their routes and build links by hand (the blog template hardcodes
For a template to actually serve + link those URLs, two pieces are needed:
I think the feature is only worth shipping if we close that second piece — i.e. export a small ---
import { getEntryUrl } from "emdash";
const url = getEntryUrl(post); // "/2018/05/08/hello.html" — same resolver the sitemap uses
---
<a href={url}>{post.data.title}</a>Then Happy to add that exported helper + a short routing example (and update the starter templates to use it) to the PR if you’re on board with the direction. The open |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
Teams migrating from WordPress want to preserve their existing permalink structure so old URLs keep working and SEO/equity is retained. WordPress lets you compose permalinks from structure tags — e.g.
/%year%/%monthnum%/%day%/%postname%/or the classic/%year%/%monthnum%/%day%/%postname%.html.EmDash collections already have a
url_pattern, but it only supports{slug}(and{id}in menus). There is no way to express a date-based permalink, so WP migrants cannot reproduce/2018/05/28/my-post.Proposal
Add date/id structure tags to
url_pattern, resolved from the entry's published date (so permalinks stay stable across edits —updated_atwould change the URL on every edit):{year}→2018{month}→05(zero-padded){day}→28{hour}{minute}{second}→ zero-padded{slug}and{id}Literal suffixes like
.htmlalready work (they are literal text in the pattern). Example pattern:/{year}/{month}/{day}/{slug}.html.I propose keeping EmDash's
{token}syntax (consistent with the existing{slug}/{id}) rather than WP's%token%.Scope (forward / presentational)
url_patternin EmDash is presentational — core does not serve content routes (no[...slug]route inpackages/core); templates own routing. So this proposal covers the canonical-URL / forward side, which is exactly where it matters:<loc>+ hreflang (interpolateUrlPattern)contentUrl)Reverse-matching an incoming
/2018/05/28/slugrequest back to an entry remains the template's job (a dated route), unchanged by this proposal.Implementation sketch
interpolateUrlPattern(packages/core/src/i18n/resolve.ts) to accept an optional publisheddateand substitute the date tokens (global replace; tokens left untouched when no valid date).handleSitemapDataselectspublished_at) and the admincontentUrl(the content item already carries its date).ContentTypeEditor) listing the available tokens.emdash+@emdash-cms/admin, minor). Nomessages.po(extracted on merge).Open questions for maintainers
{year}(EmDash style) or also accept WP%year%?packages/core/src/menus/index.ts) adopt the same tokens for consistency?Happy to open the PR as sketched once a direction is agreed. I already shipped the smaller, self-contained admin feature directly (#1524); this one is core + has the design choices above, so raising it here first per the contribution policy.
Beta Was this translation helpful? Give feedback.
All reactions