diff --git a/docs/docs/pages/config.mdx b/docs/docs/pages/config.mdx index 75444e4..4acc872 100644 --- a/docs/docs/pages/config.mdx +++ b/docs/docs/pages/config.mdx @@ -133,9 +133,12 @@ This would produce paths like `/blog/2024/01/my-post`. | Token | Description | Example | |-------|-------------|---------| | `{slug}` | The generated slug (from filepath or `slugField`) | `my-post` | -| `{year}` | Four-digit publish year | `2024` | -| `{month}` | Zero-padded publish month | `01` | -| `{day}` | Zero-padded publish day | `15` | +| `{year}` | Four-digit publish year (local time) | `2024` | +| `{yearUTC}` | Four-digit publish year (UTC) | `2024` | +| `{month}` | Zero-padded publish month (local time) | `01` | +| `{monthUTC}` | Zero-padded publish month (UTC) | `01` | +| `{day}` | Zero-padded publish day (local time) | `15` | +| `{dayUTC}` | Zero-padded publish day (UTC) | `15` | | `{title}` | Slugified post title | `my-first-post` | | `{field}` | Any frontmatter field value (string fields only) | - | diff --git a/packages/cli/src/lib/markdown.ts b/packages/cli/src/lib/markdown.ts index 1f97ece..6c6344c 100644 --- a/packages/cli/src/lib/markdown.ts +++ b/packages/cli/src/lib/markdown.ts @@ -234,8 +234,11 @@ export function getSlugFromOptions( export function resolvePathTemplate(template: string, post: BlogPost): string { const publishDate = new Date(post.frontmatter.publishDate); const year = String(publishDate.getFullYear()); + const yearUTC = String(publishDate.getUTCFullYear()); const month = String(publishDate.getMonth() + 1).padStart(2, "0"); + const monthUTC = String(publishDate.getUTCMonth() + 1).padStart(2, "0"); const day = String(publishDate.getDate()).padStart(2, "0"); + const dayUTC = String(publishDate.getUTCDate()).padStart(2, "0"); const slugifiedTitle = (post.frontmatter.title || "") .toLowerCase() @@ -246,8 +249,11 @@ export function resolvePathTemplate(template: string, post: BlogPost): string { let result = template .replace(/\{slug\}/g, post.slug) .replace(/\{year\}/g, year) + .replace(/\{yearUTC\}/g, yearUTC) .replace(/\{month\}/g, month) + .replace(/\{monthUTC\}/g, monthUTC) .replace(/\{day\}/g, day) + .replace(/\{dayUTC\}/g, dayUTC) .replace(/\{title\}/g, slugifiedTitle); // Replace any remaining {field} tokens with raw frontmatter values