Skip to content

Commit

Permalink
Clean date with content collection config, not component
Browse files Browse the repository at this point in the history
  • Loading branch information
ewels committed Mar 15, 2024
1 parent d61e323 commit 9cd2b1f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 20 deletions.
10 changes: 0 additions & 10 deletions src/components/DateStr.astro

This file was deleted.

8 changes: 6 additions & 2 deletions src/content/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ const blogCollection = defineCollection({
icon: z.string(),
tags: z.string(),
// tags: z.array(z.string()).optional(),
date: z.date(),
date: z
.date()
.transform((d) => d.getDate() + " " + d.toLocaleString("default", { month: "long" }) + " " + d.getFullYear()),
}),
});

Expand All @@ -28,7 +30,9 @@ const podcastCollection = defineCollection({
icon: z.string(),
tags: z.string(),
// tags: z.array(z.string()).optional(),
date: z.date(),
date: z
.date()
.transform((d) => d.getDate() + " " + d.toLocaleString("default", { month: "long" }) + " " + d.getFullYear()),
}),
});

Expand Down
3 changes: 1 addition & 2 deletions src/pages/blog/[...post].astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
import { getCollection } from "astro:content";
import Page from "@layouts/Page.astro";
import DateStr from "@components/DateStr.astro";
export async function getStaticPaths() {
const blogPosts = await getCollection("blog");
Expand All @@ -23,7 +22,7 @@ const tags = entry.data.tags.split(",");
<h2><a href="#">{entry.data.title}</a></h2>
<ul class="text-muted list-inline blg-header">
<li><i class="fa fa-user"></i> {entry.data.author}</li>
<li><i class="fa fa-calendar"></i> <DateStr d={entry.data.date} /></li>
<li><i class="fa fa-calendar"></i> {entry.data.date}</li>
</ul>
<hr />
<div class="blg-text">
Expand Down
3 changes: 1 addition & 2 deletions src/pages/blog/index.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
import { getCollection } from "astro:content";
import Page from "@layouts/Page.astro";
import DateStr from "@components/DateStr.astro";
const posts = (await getCollection("blog")).sort(
(a, b) => new Date(b.data.date).valueOf() - new Date(a.data.date).valueOf(),
Expand Down Expand Up @@ -29,7 +28,7 @@ const posts = (await getCollection("blog")).sort(
<i class="fa fa-user" /> {post.data.author}
</li>
<li>
<i class="fa fa-calendar" /> <DateStr d={post.data.date} />
<i class="fa fa-calendar" /> {post.data.date}
</li>
</ul>
<hr />
Expand Down
3 changes: 1 addition & 2 deletions src/pages/podcast/[...episode].astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
import { getCollection } from "astro:content";
import Page from "@layouts/Page.astro";
import DateStr from "@components/DateStr.astro";
export async function getStaticPaths() {
const episodes = await getCollection("podcast");
Expand All @@ -23,7 +22,7 @@ const tags = entry.data.tags.split(",");
<h2><a href="#">{entry.data.title}</a></h2>
<ul class="text-muted list-inline blg-header">
<li><i class="fa fa-user"></i> {entry.data.author}</li>
<li><i class="fa fa-calendar"></i> <DateStr d={entry.data.date} /></li>
<li><i class="fa fa-calendar"></i> {entry.data.date}</li>
</ul>
<hr />
<div class="blg-text">
Expand Down
3 changes: 1 addition & 2 deletions src/pages/podcasts.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
import { getCollection } from "astro:content";
import Page from "@layouts/Page.astro";
import DateStr from "@components/DateStr.astro";
const episodes = (await getCollection("podcast")).sort(
(a, b) => new Date(b.data.date).valueOf() - new Date(a.data.date).valueOf(),
Expand Down Expand Up @@ -43,7 +42,7 @@ const episodes = (await getCollection("podcast")).sort(
<i class="fa fa-info-circle" /> {post.data.subtype}
</li>
<li>
<i class="fa fa-calendar" /> <DateStr d={post.data.date} />
<i class="fa fa-calendar" /> {post.data.date}
</li>
</ul>
<hr />
Expand Down

0 comments on commit 9cd2b1f

Please sign in to comment.