WIP: app -> pages

This commit is contained in:
2023-06-14 22:25:00 +04:00
parent a4bed55547
commit d7ed76ae6e
14 changed files with 109 additions and 82 deletions

View File

@@ -0,0 +1,38 @@
import { notFound } from 'next/navigation'
import directus from '~/lib/directus'
export const getStaticPaths = async () => {
const { data: pages } = await directus.items('pages').readByQuery({
limit: 1,
})
return {
paths: pages.map((p) => ({ params: { slug: p.slug } })),
fallback: false, // false or "blocking"
}
}
export const getStaticProps = async ({ params }) => {
const { slug } = params
const {
data: [page],
} = await directus.items('pages').readByQuery({
limit: 1,
filter: {
slug: {
_eq: slug,
},
},
})
return { props: { page } }
}
export default function Page({ page }) {
return (
<div>
<h1>{page.title}</h1>
<div dangerouslySetInnerHTML={{ __html: page.content }}></div>
</div>
)
}