This commit is contained in:
2023-06-15 00:11:07 +04:00
parent 24222f4521
commit 293b6ea295
6 changed files with 395 additions and 323 deletions

View File

@@ -1,17 +1,17 @@
import directus from '~/lib/directus'
export const getServerSideProps = async () => {
const { data: pages } = await directus.items('pages').readByQuery({
limit: 1,
})
// export const getServerSideProps = 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"
}
}
// return {
// paths: pages.map((p) => ({ params: { slug: p.slug } })),
// fallback: false, // false or "blocking"
// }
// }
export const getStaticProps = async ({ params }) => {
export const getServerSideProps = async ({ params }) => {
const { slug } = params
const {
@@ -24,6 +24,9 @@ export const getStaticProps = async ({ params }) => {
},
},
})
if (!page) return { notFound: true }
return { props: { page } }
}

View File

@@ -151,7 +151,7 @@ async function importVendors() {
)
}
export default async function Home() {
export default function Home() {
// importCategories()
// importSubcategories()
// importCategoryStructure()

View File

@@ -1,4 +1,3 @@
import { notFound } from 'next/navigation'
import directus from '~/lib/directus'
export const getServerSideProps = async ({ params }) => {
@@ -20,7 +19,7 @@ export const getServerSideProps = async ({ params }) => {
filter: { slug: { _eq: slug } },
})
if (!vendor) return notFound()
if (!vendor) return { notFound: true }
return { props: { vendor } }
}
@@ -79,7 +78,7 @@ export default function VendorPage({ vendor }) {
<h2>Categories</h2>
<ul>
{vendor.categories.map((cat) => (
<li>{cat.categories_id.name}</li>
<li key={cat.id}>{cat.categories_id.name}</li>
))}
</ul>
</>