1 ---
2 import { type CollectionEntry, getCollection } from 'astro:content'
3 import PostLayout from '@/layouts/PostLayout.astro'
4 import { render } from 'astro:content'
5
6 export async function getStaticPaths() {
7 const posts = await getCollection('posts')
8 const paths = []
9
10 // Filter out draft posts (starting with _)
11 const publishedPosts = posts.filter((post) => !post.id.startsWith('_'))
12
13 for (const post of publishedPosts) {
14 // Check if it's an English post
15 if (post.id.startsWith('en/')) {
16 const slug = post.id.replace('en/', '')
17 paths.push({
18 params: { slug: `en/${slug}` },
19 props: post
20 })
21 } else {
22 // Indonesian post (default)
23 paths.push({
24 params: { slug: post.id },
25 props: post
26 })
27 }
28 }
29
30 return paths
31 }
32 type Props = CollectionEntry<'posts'>
33
34 const post = Astro.props
35 const { Content, remarkPluginFrontmatter } = await render(post)
36
37 const readingTime = remarkPluginFrontmatter.readingTime
38 const toc = remarkPluginFrontmatter.toc || []
39 ---
40
41 <PostLayout {...post.data} readingTime={readingTime} toc={toc}>
42 <Content />
43 </PostLayout>