Skip to content

Instantly share code, notes, and snippets.

@jhilker98
Created July 11, 2023 19:39
Show Gist options
  • Save jhilker98/f09fe6519df5fa7fd51f23637be9f43e to your computer and use it in GitHub Desktop.
Save jhilker98/f09fe6519df5fa7fd51f23637be9f43e to your computer and use it in GitHub Desktop.
broken blog layout setup
---
import { getCollection, CollectionEntry } from "astro:content";
import Layout from "../../layouts/Layout.astro";
export async function getStaticPaths() {
const posts = await getCollection('blog');
return posts.map((post) => {
const year = post.data.date.getFullYear();
post.slug = `/${year}/${post.slug}`;
return {
params: {
slug: post.slug,
},
props: {
post,
},
};
});
}
interface Props {
post: CollectionEntry<'blog'>;
}
const { post } = Astro.props;
const { Content } = await post.render();
---
<Layout title={post.data.title}>
<header>
<h1>{post.data.title}</h1>
<a href={post.slug}>Read More</a>
</header>
<Content />
</Layout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment