Hi there, I am creating a multi language website in English and Spanish (using slice machine)
My pages folder structure setup is as below:
pages/
├─ _lang/
│ ├─ index.vue
│ ├─ _uid.vue
│ ├─ visit/
│ │ ├─ index.vue
├─ _uid.vue
├─ index.vue
├─ visit/
│ ├─ index.vue
Homepage & _uid work fine, but I'm running into problems with accessing the Spanish versions of the /visit/ page using $prismic.api.getSingle.
I can access the English page perfectly at http://localhost:3000/en-us/visit
But when I switch language to Spanish it comes unstuck at: http://localhost:3000/es-ar/visitar with a 'This page could not be found' error
However using the english doc.uid http://localhost:3000/es-ar/visit/ works
I don't want to hardcode anything and for this project, I really need dynamic UID's between languages
_lang/visit/index.vue is setup as follows:
async asyncData({ $prismic, params, error }) {
const visit = await $prismic.api.getSingle("visit", { lang: params.lang });
const translations = visit.alternate_languages;
return { visit, translations, lang: visit.lang };
},
And my link-resolver as below:
export default function (doc) {
if (doc.type === "home") {
return `/${doc.lang}`;
}
if (doc.type === "page") {
return `/${doc.lang}/page/${doc.uid}`;
}
if (doc.type === "visit") {
return `/${doc.lang}/${doc.uid}`;
}
return "/not-found";
}
What am I doing wrong here?
Any tips would be greatly appreciated!