diff --git a/src/pages/[[...path]].jsx b/src/pages/[[...path]].jsx index 2ecd012..3b86b55 100644 --- a/src/pages/[[...path]].jsx +++ b/src/pages/[[...path]].jsx @@ -8,29 +8,30 @@ import { } from 'next-mdx-remote-client/serialize' import { NextSeo } from 'next-seo' -export async function getStaticPaths () { - const res = await fetchBasicPages(['path']) +// export async function getStaticPaths () { +// const res = await fetchBasicPages(['path']) - if (!res.ok) { - throw new FailedFetchBasicPagesError(await res.text()) - } +// if (!res.ok) { +// throw new FailedFetchBasicPagesError(await res.text()) +// } - const pages = (await res.json()).data +// const pages = (await res.json()).data - const paths = { - paths: pages.map(page => ({ - params: { - path: page.path?.split('/') // about/page -> [about, page] - .filter(p => !!p) ?? [] // deal with paths starting with '/' - } - })), - fallback: true // false or "blocking" - } +// const paths = { +// paths: pages.map(page => ({ +// params: { +// path: page.path?.split('/') // about/page -> [about, page] +// .filter(p => !!p) ?? [] // deal with paths starting with '/' +// } +// })), +// fallback: true // false or "blocking" +// } - return paths -} -export async function getStaticProps ({ params }) { +// return paths +// } +export async function getServerSideProps ({ params }) { const { path } = params + console.log(params) const res = await fetchBasicPages([], { path: { _eq: path?.join('/') ?? null diff --git a/src/pages/library/[slug].js b/src/pages/library/[slug].js index e384994..03608b6 100644 --- a/src/pages/library/[slug].js +++ b/src/pages/library/[slug].js @@ -4,27 +4,28 @@ import BookReview from '@/components/Book/BookReview' import { fetchBookReviews, markdownToHtml } from '@/services/content-service' import { FailedFetchBookReviewError, FailedFetchBookReviewsError } from '@/errors' -export async function getStaticPaths () { - const res = await fetchBookReviews(['slug'], { - status: 'published' - }) +// export async function getStaticPaths () { +// const res = await fetchBookReviews(['slug'], { +// status: 'published' +// }) - if (!res.ok) { - throw new FailedFetchBookReviewsError(await res.text()) - } +// if (!res.ok) { +// throw new FailedFetchBookReviewsError(await res.text()) +// } - const reviews = (await res.json()).data +// const reviews = (await res.json()).data - return { - paths: reviews.map(post => ({ - params: { - slug: post.slug - } - })), - fallback: false // false or "blocking" - } -} -export const getStaticProps = async ({ params }) => { +// return { +// paths: reviews.map(post => ({ +// params: { +// slug: post.slug +// } +// })), +// fallback: false // false or "blocking" +// } +// } + +export const getServerSideProps = async ({ params }) => { const { slug } = params if (!slug) { diff --git a/src/pages/library/index.js b/src/pages/library/index.js index f801954..8b2c725 100644 --- a/src/pages/library/index.js +++ b/src/pages/library/index.js @@ -8,7 +8,7 @@ import { NextSeo } from 'next-seo' export const Title = 'Library' -export async function getStaticProps () { +export async function getServerSideProps () { const res = await fetchBookReviews() if (!res.ok) { diff --git a/src/pages/writing/[slug].js b/src/pages/writing/[slug].js index 4cf9602..9988eea 100644 --- a/src/pages/writing/[slug].js +++ b/src/pages/writing/[slug].js @@ -4,27 +4,28 @@ import Article from '@/components/Article/Article' import { fetchPosts, markdownToHtml } from '@/services/content-service' import { FailedFetchPostError, FailedFetchPostsError } from '@/errors' -export async function getStaticPaths () { - const res = await fetchPosts(['slug'], { - status: 'published' - }) +// export async function getStaticPaths () { +// const res = await fetchPosts(['slug'], { +// status: 'published' +// }) - if (!res.ok) { - throw new FailedFetchPostsError(await res.text()) - } +// if (!res.ok) { +// throw new FailedFetchPostsError(await res.text()) +// } - const posts = (await res.json()).data +// const posts = (await res.json()).data - return { - paths: posts.map(post => ({ - params: { - slug: post.slug - } - })), - fallback: true // false or "blocking" - } -} -export const getStaticProps = async ({ params }) => { +// return { +// paths: posts.map(post => ({ +// params: { +// slug: post.slug +// } +// })), +// fallback: true // false or "blocking" +// } +// } + +export const getServerSideProps = async ({ params }) => { const { slug } = params const res = await fetchPosts([], { slug,