diff --git a/frontmatter.json b/frontmatter.json index ad6d540..d6fea6d 100644 --- a/frontmatter.json +++ b/frontmatter.json @@ -16,12 +16,20 @@ "type": "string" }, { - "title": "Publishing date", + "title": "Date published", "name": "pubDate", "type": "datetime", "default": "{{now}}", "isPublishDate": true }, + { + "title": "Date last edited", + "name": "lastEditDate", + "type": "datetime", + "default": "{{now}}", + "isModifiedDate": true, + "required": false + }, { "title": "Draft", "name": "draft", diff --git a/src/content/config.ts b/src/content/config.ts index d8b87a2..3b13bbe 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -9,6 +9,11 @@ const blog = defineCollection({ .string() .or(z.date()) .transform((val) => new Date(val)), + lastEditDate: z + .string() + .or(z.date()) + .transform((val) => new Date(val)) + .optional(), tags: z.string().array(), categories: z.string().array() }) diff --git a/src/layouts/BlogPost.astro b/src/layouts/BlogPost.astro index 1fa34a2..1210200 100644 --- a/src/layouts/BlogPost.astro +++ b/src/layouts/BlogPost.astro @@ -6,7 +6,8 @@ import FormattedDate from '../components/FormattedDate.astro'; type Props = CollectionEntry<'blog'>['data']; -const { title, description, pubDate, draft, tags, categories } = Astro.props; +const { title, description, pubDate, lastEditDate, draft, tags, categories } = + Astro.props; const [category] = categories; --- @@ -15,6 +16,15 @@ const [category] = categories;

{title}

date published:

+ { + lastEditDate && ( +

+ + date edited: + +

+ ) + }

category: