mirror of
https://github.com/maciejpedzich/maciejpedzi.ch.git
synced 2024-11-27 15:45:47 +01:00
Add and display last edited date field
This commit is contained in:
parent
8e178d2b5c
commit
bce0a61029
@ -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",
|
||||
|
@ -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()
|
||||
})
|
||||
|
@ -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;
|
||||
<h1 class="title">{title}</h1>
|
||||
<div id="metadata">
|
||||
<p>date published: <FormattedDate date={pubDate} /></p>
|
||||
{
|
||||
lastEditDate && (
|
||||
<p>
|
||||
<em>
|
||||
date edited: <FormattedDate date={lastEditDate} />
|
||||
</em>
|
||||
</p>
|
||||
)
|
||||
}
|
||||
<p>
|
||||
category:
|
||||
<span>
|
||||
|
Loading…
Reference in New Issue
Block a user