Hello @Priyanka
Thank you for your feedback.
We have followed your piece of advice such as job.city, in our case: boston.data-analyst
That actually solve this ticket: Duplicate This value is already used by another job_localization document (URL build with content relationship)
Although, we really wanted to avoid having various subfolders for our different custom types, so we have to make multiple custom type requests in the same jobs > [uid].ts file:
I guess it's not prismic-friendly, but product wise we need it to be nested such as jobs/uid_of_custom_type_1, jobs/uid_of_custom_type_2, etc.
export async function getStaticProps(props) {
const { params, previewData } = props
const client = createClient({ previewData })
let page = null
for (const type of [
'pillar_page',
'job_category',
'city',
'country',
'job_title'
]) {
try {
page = await client.getByUID(
type as
| 'pillar_page'
| 'job_category'
| 'job_title'
| 'city'
| 'country',
params.uid
)
if (page) {
break
}
} catch (error) {}
}
const similarPages = await getSimilarPages({ client, page })
const slices = await Promise.all(
page.data.slices.map(async (slice) => {
if (
slice.slice_type === 'reusable_topic_info' &&
slice.primary.reusabletopic.id
) {
const topic = await client.getByID(slice.primary.reusabletopic.id)
slice.primary.reusabletopic = topic
return slice
}
return slice
})
)
return {
props: {
metaTitle: page.data.meta_title,
metaDescription: page.data.meta_description,
ogImage: page.data.og_image.url,
upperTitle: page.data?.upper_title,
title: page.data?.title,
description: page.data?.description,
keyword: page.data?.keyword,
url: page.url,
slices,
similarPages
}
}
}
export async function getStaticPaths() {
const client = createClient()
const pillarPages = await client.getAllByType('pillar_page')
const jobCategoryPages = await client.getAllByType('job_category')
const jobTitlePages = await client.getAllByType('job_title')
const cityPages = await client.getAllByType('city')
const countryPages = await client.getAllByType('country')
const paths = [
...pillarPages,
...jobCategoryPages,
...jobTitlePages,
...cityPages,
...countryPages
].map((page) => prismicH.asLink(page))
return {
paths,
fallback: false
}
}