mirror of
https://github.com/maciejpedzich/maciejpedzi.ch.git
synced 2024-11-27 23:55: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"
|
"type": "string"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Publishing date",
|
"title": "Date published",
|
||||||
"name": "pubDate",
|
"name": "pubDate",
|
||||||
"type": "datetime",
|
"type": "datetime",
|
||||||
"default": "{{now}}",
|
"default": "{{now}}",
|
||||||
"isPublishDate": true
|
"isPublishDate": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"title": "Date last edited",
|
||||||
|
"name": "lastEditDate",
|
||||||
|
"type": "datetime",
|
||||||
|
"default": "{{now}}",
|
||||||
|
"isModifiedDate": true,
|
||||||
|
"required": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"title": "Draft",
|
"title": "Draft",
|
||||||
"name": "draft",
|
"name": "draft",
|
||||||
|
@ -9,6 +9,11 @@ const blog = defineCollection({
|
|||||||
.string()
|
.string()
|
||||||
.or(z.date())
|
.or(z.date())
|
||||||
.transform((val) => new Date(val)),
|
.transform((val) => new Date(val)),
|
||||||
|
lastEditDate: z
|
||||||
|
.string()
|
||||||
|
.or(z.date())
|
||||||
|
.transform((val) => new Date(val))
|
||||||
|
.optional(),
|
||||||
tags: z.string().array(),
|
tags: z.string().array(),
|
||||||
categories: z.string().array()
|
categories: z.string().array()
|
||||||
})
|
})
|
||||||
|
@ -6,7 +6,8 @@ import FormattedDate from '../components/FormattedDate.astro';
|
|||||||
|
|
||||||
type Props = CollectionEntry<'blog'>['data'];
|
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;
|
const [category] = categories;
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -15,6 +16,15 @@ const [category] = categories;
|
|||||||
<h1 class="title">{title}</h1>
|
<h1 class="title">{title}</h1>
|
||||||
<div id="metadata">
|
<div id="metadata">
|
||||||
<p>date published: <FormattedDate date={pubDate} /></p>
|
<p>date published: <FormattedDate date={pubDate} /></p>
|
||||||
|
{
|
||||||
|
lastEditDate && (
|
||||||
|
<p>
|
||||||
|
<em>
|
||||||
|
date edited: <FormattedDate date={lastEditDate} />
|
||||||
|
</em>
|
||||||
|
</p>
|
||||||
|
)
|
||||||
|
}
|
||||||
<p>
|
<p>
|
||||||
category:
|
category:
|
||||||
<span>
|
<span>
|
||||||
|
Loading…
Reference in New Issue
Block a user