Skip to content

Commit

Permalink
feat: improve last modified remark plugin use
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcalexandre committed Jul 18, 2024
1 parent a7c2b08 commit 47adc08
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/layouts/BlogPostLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import dayjs from "dayjs";
import timezone from "dayjs/plugin/timezone";
import utc from "dayjs/plugin/utc";
dayjs.extend(utc);
dayjs.extend(timezone);
import BaseLayout from "./BaseLayout.astro";
const { frontmatter, readingTime } = Astro.props;
dayjs.extend(utc);
dayjs.extend(timezone);
const formattedLastModified = dayjs(frontmatter.lastModified)
.utc()
.tz("Europe/Paris")
Expand Down
6 changes: 3 additions & 3 deletions src/layouts/MarkdownPageLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import dayjs from "dayjs";
import timezone from "dayjs/plugin/timezone";
import utc from "dayjs/plugin/utc";
dayjs.extend(utc);
dayjs.extend(timezone);
import BaseLayout from "./BaseLayout.astro";
const { frontmatter } = Astro.props;
dayjs.extend(utc);
dayjs.extend(timezone);
const lastModified = dayjs(frontmatter.lastModified)
.utc()
.tz("Europe/Paris")
Expand Down
9 changes: 0 additions & 9 deletions src/pages/blog/[...slug].astro
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
---
import BlogPostLayout from "@/layouts/BlogPostLayout.astro";
import { getCollection } from "astro:content";
import dayjs from "dayjs";
import timezone from "dayjs/plugin/timezone";
dayjs.extend(timezone);
export async function getStaticPaths() {
const blogEntries = await getCollection("posts");
Expand All @@ -16,15 +12,10 @@ export async function getStaticPaths() {
const { entry } = Astro.props;
const { Content, remarkPluginFrontmatter } = await entry.render();
const lastModified = dayjs(remarkPluginFrontmatter.lastModified)
.tz("Europe/Paris")
.format("DD MMMM YYYY HH:mm:ss");
---

<BlogPostLayout
frontmatter={entry.data}
lastModified={lastModified}
readingTime={remarkPluginFrontmatter.minutesRead}>
<section class="text-dark-900 dark:text-neutral-100">
<Content />
Expand Down

0 comments on commit 47adc08

Please sign in to comment.