Skip to content

Instantly share code, notes, and snippets.

@ehsann95
Created Oct 26, 2021
Embed
What would you like to do?
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