Add auto updating last modified code to blog posts
This commit is contained in:
parent
9c6d49e14f
commit
92992c6142
6 changed files with 36 additions and 3 deletions
|
@ -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>
|
Loading…
Add table
Add a link
Reference in a new issue