generated from chrismwilliams/astro-theme-cactus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
[...slug}.astro
44 lines (39 loc) · 1.2 KB
/
[...slug}.astro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---
import type { GetStaticPaths, InferGetStaticPropsType } from "astro";
import DailyLayout from "@/layouts/BlogPost.astro";
import { getCollection, type CollectionEntry } from "astro:content";
export async function getStaticPaths() {
const dailies = await getCollection("dailies", ({ data }) => {
return import.meta.env.PROD ? data.draft !== true : true;
});
return dailies.map((post) => ({
params: { slug: post.slug },
props: dailies,
}));
}
type Props = CollectionEntry<"dailies">;
const dailies = Astro.props;
const { headings, Content } = await entry.render();
---
<DailyLayout title={dailies.data.title} description={dailies.data.description}>
<header class="pb-8 pt-40 border-b border-primary">
<h1 class="font-semibold">{dailies.data.title}</h1>
<p class="text-secondary mt-1">{dailies.data.description}</p>
</header>
{
dailies.data.toc ? (
<section class="pt-8 pb-16 relative grid sm:grid-cols-3 items-start gap-x-8">
<TableOfContents headings={headings} />
<article class="sm:col-span-2 prose">
<Content />
</article>
</section>
) : (
<section class="pt-8 pb-16">
<article class="prose">
<Content />
</article>
</section>
)
}
</DailyLayout>