+12
-3
Diff
round #0
+6
-3
docs/docs/pages/config.mdx
+6
-3
docs/docs/pages/config.mdx
···
133
133
| Token | Description | Example |
134
134
|-------|-------------|---------|
135
135
| `{slug}` | The generated slug (from filepath or `slugField`) | `my-post` |
136
-
| `{year}` | Four-digit publish year | `2024` |
137
-
| `{month}` | Zero-padded publish month | `01` |
138
-
| `{day}` | Zero-padded publish day | `15` |
136
+
| `{year}` | Four-digit publish year (local time) | `2024` |
137
+
| `{yearUTC}` | Four-digit publish year (UTC) | `2024` |
138
+
| `{month}` | Zero-padded publish month (local time) | `01` |
139
+
| `{monthUTC}` | Zero-padded publish month (UTC) | `01` |
140
+
| `{day}` | Zero-padded publish day (local time) | `15` |
141
+
| `{dayUTC}` | Zero-padded publish day (UTC) | `15` |
139
142
| `{title}` | Slugified post title | `my-first-post` |
140
143
| `{field}` | Any frontmatter field value (string fields only) | - |
141
144
+6
packages/cli/src/lib/markdown.ts
+6
packages/cli/src/lib/markdown.ts
···
234
234
export function resolvePathTemplate(template: string, post: BlogPost): string {
235
235
const publishDate = new Date(post.frontmatter.publishDate);
236
236
const year = String(publishDate.getFullYear());
237
+
const yearUTC = String(publishDate.getUTCFullYear());
237
238
const month = String(publishDate.getMonth() + 1).padStart(2, "0");
239
+
const monthUTC = String(publishDate.getUTCMonth() + 1).padStart(2, "0");
238
240
const day = String(publishDate.getDate()).padStart(2, "0");
241
+
const dayUTC = String(publishDate.getUTCDate()).padStart(2, "0");
239
242
240
243
const slugifiedTitle = (post.frontmatter.title || "")
241
244
.toLowerCase()
···
246
249
let result = template
247
250
.replace(/\{slug\}/g, post.slug)
248
251
.replace(/\{year\}/g, year)
252
+
.replace(/\{yearUTC\}/g, yearUTC)
249
253
.replace(/\{month\}/g, month)
254
+
.replace(/\{monthUTC\}/g, monthUTC)
250
255
.replace(/\{day\}/g, day)
256
+
.replace(/\{dayUTC\}/g, dayUTC)
251
257
.replace(/\{title\}/g, slugifiedTitle);
252
258
253
259
// Replace any remaining {field} tokens with raw frontmatter values
History
1 round
0 comments
heaths.dev
submitted
#0
1 commit
expand
collapse
Add UTC date path template variables
expand 0 comments
pull request successfully merged