This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function getStaticPaths() { | |
let { data } = await Storyblok.get('cdn/links/', { | |
starts_with: 'products/', | |
version: 'draft', | |
}); | |
let paths = []; | |
Object.keys(data.links).forEach((linkKey) => { | |
// don't create routes for folders and the index page | |
if (data.links[linkKey].is_folder) { | |
return; | |
} | |
// get array for slug because of catch all | |
const slug = data.links[linkKey].slug; | |
// remove the pages part from the slug | |
let newSlug = slug.replace('products', ''); | |
let splittedSlug = newSlug.split('/')[1]; | |
paths.push({ params: { product: splittedSlug } }); | |
}); | |
return { | |
paths: paths, | |
fallback: false, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment