Skip to content

Commit eed9f85

Browse files
committed
prerender 404 pages with a table of contents of all examples
1 parent abc7118 commit eed9f85

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

packages/@headlessui-react/pages/_app.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function KeyCaster() {
105105

106106
function MyApp({ Component, pageProps }) {
107107
const router = useRouter()
108-
const { allExamples = [] } = pageProps
108+
const { examples = [] } = pageProps
109109

110110
return (
111111
<>
@@ -138,7 +138,7 @@ function MyApp({ Component, pageProps }) {
138138
alt="Tailwind UI"
139139
/>
140140
</NextLink>
141-
{allExamples.length > 0 && (
141+
{examples.length > 0 && (
142142
<div>
143143
<select
144144
value={router.asPath}
@@ -147,7 +147,7 @@ function MyApp({ Component, pageProps }) {
147147
}}
148148
className="block w-full py-2 pl-3 pr-10 text-base leading-6 border-gray-300 form-select focus:outline-none focus:shadow-outline-blue focus:border-blue-300 sm:text-sm sm:leading-5"
149149
>
150-
<RecursiveExamplesSelectOptions examples={allExamples} />
150+
<RecursiveExamplesSelectOptions examples={examples} />
151151
</select>
152152
</div>
153153
)}

packages/@headlessui-react/pages/_error.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react'
2-
import { NextApiRequest } from 'next'
32
import Error from 'next/error'
43
import Head from 'next/head'
54
import Link from 'next/link'
@@ -16,11 +15,10 @@ function NextLink(props: PropsOf<'a'>) {
1615
)
1716
}
1817

19-
export async function getServerSideProps({ req }: { req: NextApiRequest }) {
18+
export async function getStaticProps() {
2019
return {
2120
props: {
22-
allExamples: await resolveAllExamples('pages'),
23-
examples: await resolveAllExamples('pages', ...req.url.split('/').slice(1)),
21+
examples: await resolveAllExamples('pages'),
2422
},
2523
}
2624
}

0 commit comments

Comments
 (0)