Skip to content

Commit 629dd4f

Browse files
Merge pull request #26 from regulate-tech/paperless-slug
fix: output as paperless.html
2 parents 7e1154b + feb37b2 commit 629dd4f

File tree

3 files changed

+13
-24
lines changed

3 files changed

+13
-24
lines changed

docs/posts/2024-10-01-paperless.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
layout: default
33
title: Paperless NHS
4+
slug: paperless.html
45
---
56

67
The NHS has committed to replacing paper medical records with digital records several times, but this has not happened.

docs/public/paperless.html

Lines changed: 0 additions & 19 deletions
This file was deleted.

docs/src/content.config.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@ const posts = defineCollection({
66
base: 'posts',
77
pattern: '**/*.md',
88
generateId: ({entry, data}) => {
9-
const id = entry.slice(11, -3)
10-
const pubDate = data.pubDate ?? entry.slice(0, 10)
11-
// Note: mutating the data obj. serves them right for passing it in unfrozen.
12-
data.pubDate = pubDate
13-
return id
9+
// Note: jekyll pulls the pubDate and the slug from filename,
10+
// so we recreate that here by adding the pubDate where unset
11+
if (!data.pubDate) {
12+
// first 10 chars should be a hyphenated ISO8601 date.
13+
data.pubDate = entry.slice(0, 10)
14+
}
15+
if (data.slug && typeof data.slug === 'string') {
16+
// use the `slug` prop from the frontmatter if specified.
17+
return data.slug
18+
}
19+
// chars after the iso date are teh slug, minus the `.md` suffix
20+
return entry.slice(11, -3)
1421
}
1522
}),
1623
schema: z.object({

0 commit comments

Comments
 (0)