Add auto updating last modified code to blog posts

This commit is contained in:
Aria 2025-03-10 13:31:51 +11:00
parent 9c6d49e14f
commit 92992c6142
Signed by untrusted user who does not match committer: aria
GPG key ID: 19AB7AA462B8AB3B
6 changed files with 36 additions and 3 deletions

View file

@ -1,5 +1,10 @@
---
import { getCollection, render } from "astro:content";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
dayjs.extend(utc);
import MarkdownPostLayout from "../../layouts/MarkdownPostLayout.astro";
export async function getStaticPaths() {
@ -11,8 +16,12 @@ export async function getStaticPaths() {
}
const { post } = Astro.props;
const { Content } = await render(post);
const { Content, remarkPluginFrontmatter } = await render(post);
const lastModified = dayjs(remarkPluginFrontmatter.lastModified)
.utc()
.format("HH:mm:ss DD MMMM YYYY UTC");
---
<MarkdownPostLayout frontmatter={post.data}>
<MarkdownPostLayout frontmatter={post.data} lastModified={lastModified}>
<Content />
</MarkdownPostLayout>