Home route when no home specific collection type (ie, page only)

Hi there,

I'm helping a client setup his new Prismic site and am trying to keep the collection types to a minimum, so for my home page I'm using the Page collection type.

I tried adding the following to my link-resolver:

if (doc.type === 'page' && doc.uid === 'home') {
return '/'

}

But that just results in a page error.

Any ideas what I'm doing wrong?

Thanks,
Chris

Hello Leon,

Welcome to the Prismic Forum.

I am sorry, but I need more information on this question? Can you describe it a little more? Or It would be better if you can share the repo URL and source code with me.

I am looking forward to hearing back from you.

Thanks,

Priyanka

Hi Priyanka,

It's Chris. Leon is the account holder.

The github repo is private, but if you pm me your github username I'll temporarily add you to the repo.

I have a single Page collection in Prismic. The home page is made up of slices (like all the other pages) and has a slug of "home". In my link resolver i'm pointing the page with the home uid to my home route (/).

export default function (doc) {

if (doc.isBroken) {
return '/not-found'
}
//console.log(doc);

if (doc.uid === 'home') {
return '/';
}

if (doc.type === 'page') {
return '/' + doc.uid
}

return '/not-found'
}

In my index.vue I'm outputting the single home content with

const document = await $prismic.api.getByUID("page", "home");

and

<slices :slices="document.data.body" />

Hope that clarifies the issue.

Managed to figure it out. I needed to move the home definition below the page one.

Hello @leon

I am glad that you managed to solve your issue. Don't hesitate to reach out to us If you have any doubt.

Thanks,

Priyanka

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.