storyblok / react-next-boilerplate

Nextjs Storyblok boilerplate
https://www.storyblok.com/tp/add-a-headless-cms-to-next-js-in-5-minutes
64 stars 34 forks source link

[...slug].js dev mode will not show draft entries #34

Open enddevNZ opened 2 years ago

enddevNZ commented 2 years ago
`export async function getStaticPaths() {
    const storyblokApi = getStoryblokApi();
    let { data } = await storyblokApi.get("cdn/links/");

    let paths = [];
    Object.keys(data.links).forEach((linkKey) => {
      if (data.links[linkKey].is_folder || data.links[linkKey].slug === "home") {
        return;
      }

      const slug = data.links[linkKey].slug;
      let splittedSlug = slug.split("/");

      paths.push({ params: { slug: splittedSlug } });
   });

    return {
      paths: paths,
      fallback: false,
    };
}`

No sbParams included in the links call on your template, confused me when trying to view draft stories in dev mode. I kept getting errors that the story did not exist, only once published it worked.