Move posts to separate folder, update URLs to use slugs

This commit is contained in:
Cassidy Williams
2022-08-26 00:36:03 -05:00
parent 463ee505e8
commit 32425613cd
32 changed files with 53 additions and 59 deletions

View File

@@ -7,7 +7,7 @@ import Post from '../components/Post.astro';
import { SITE_TITLE, SITE_DESCRIPTION } from '../config';
// Use Astro.glob() to fetch all posts, and then sort them by date.
const posts = (await Astro.glob('./post/*.{md,mdx}')).sort(
const posts = (await Astro.glob('../posts/*.{md,mdx}')).sort(
(a, b) => new Date(b.frontmatter.added).valueOf() - new Date(a.frontmatter.added).valueOf()
);
---
@@ -34,21 +34,6 @@ const posts = (await Astro.glob('./post/*.{md,mdx}')).sort(
<main>
<content>
<ul>
{posts.map((post) => (
<li>
<time datetime={post.frontmatter.added}>
{new Date(post.frontmatter.added).toLocaleDateString('en-us', {
year: 'numeric',
month: 'short',
day: 'numeric',
})}
</time>
<a href={post.url}>{post.frontmatter.title}</a>
</li>
))}
</ul>
<ul>
{posts.map(
({url, frontmatter: { description, slug, title, tags, added: date }}) => (
<Post {url} {description} {date} {slug} {title} {tags} />