Skip to content

Commit

Permalink
Add generateStaticParams
Browse files Browse the repository at this point in the history
  • Loading branch information
trpfrog committed Dec 29, 2024
1 parent 71b5ecc commit 5d3aa09
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/trpfrog.net/src/app/blog/[slug]/[[...options]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { fetchPost, fetchPostList } from '@blog/rpc'
import { ArticleSidebar } from './_components/ArticleSidebar'
import { EntryButtons } from './_components/EntryButtons'

export const dynamicParams = false
export const dynamicParams = true

// 1, 2, 3, ... or 'all'
const pageNumberSchema = z.coerce.number().int().positive().or(z.literal('all'))
Expand All @@ -31,6 +31,10 @@ type PageProps = {
params: Promise<z.input<typeof paramsSchema>>
}

export async function generateStaticParams() {
return [{ options: undefined }, { options: ['all'] }]
}

export async function generateMetadata(props: PageProps) {
const params = await props.params

Expand Down
7 changes: 7 additions & 0 deletions apps/trpfrog.net/src/app/blog/[slug]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import * as React from 'react'

import { fetchSlugs } from '@blog/rpc'

export async function generateStaticParams() {
const slugs = await fetchSlugs()
return slugs.map(slug => ({ slug }))
}

export default function Layout(props: { children: React.ReactNode }) {
return props.children
}

0 comments on commit 5d3aa09

Please sign in to comment.