Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose slug, uuid of page to StoryblokStory #1230

Open
1 task done
esilver-automox opened this issue Sep 11, 2024 · 0 comments
Open
1 task done

Expose slug, uuid of page to StoryblokStory #1230

esilver-automox opened this issue Sep 11, 2024 · 0 comments
Labels
pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised

Comments

@esilver-automox
Copy link

Description

I am using the Storyblok SDK with Nextjs using the app router. When setting up my app for use and using StoryblokStory in my [...slug]/page.tsx I pass it the whole storyblok story object but what is exposed to my underlying page type is the story.content object. This does not have access to the uuid of the story or the slug of the page which is necessary for me to fetch secondary data.

Suggested solution or improvement

Expose the whole story object to the StoryblokStory
OR
have options to pass uuid, slug to the StoryblokStory

Additional context

my [...slug]/page.tsx looks like

export async function fetchData(slug) {
  const version = process.env.NEXT_PUBLIC_SB_VERSION === 'published' ? 'published' : 'draft'
  const storyblokAPI = getStoryblokApi()
  return storyblokAPI.get(`cdn/stories/${slug}`, {version})
}


export default async function SBPage({params}: {params: {slug: string[]}}) {
  const slug = params.slug ? params.slug.join("/") : "";
  const {data} = await fetchData(slug)

  return (
    <div>
      <StoryblokStory story={data.story} />
    </div>
  );

and one of my underlying page types looks like

export default function Author({blok, slug}){
  // slug is undefined
  const slugFromBlok = blok.full_slug // also undefined
  const uuid = blok.uuid // also undefined but I really need this for fetching further info
  // display code here
  {(blok.body || []).map((nestedBlok) => {
    return <StoryblokComponent blok={nestedBlok} key={nestedBlok._uid} />
  })}
}

Validations

@esilver-automox esilver-automox added pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised labels Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised
Projects
None yet
Development

No branches or pull requests

1 participant