-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(website): add basic setup for Storyblok
Add initialization and providers to start using Storyblok in the website
- Loading branch information
1 parent
f53927b
commit b9fe701
Showing
2 changed files
with
45 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,30 @@ | ||
import { ContextProviders } from '@/app/context-providers'; | ||
import StoryblokProvider from '@/components/storyblok/storyblok-provider'; | ||
import { getMetadata } from '@/metadata'; | ||
import { apiPlugin, storyblokInit } from '@storyblok/react'; | ||
import { PropsWithChildren } from 'react'; | ||
import './globals.css'; | ||
|
||
// Import without component definition. This is for server-side rendering. | ||
// The client-side initailization is done in `components/storyblok-provider.tsx` | ||
storyblokInit({ | ||
accessToken: process.env.NEXT_PUBLIC_STORYBLOK_PREVIEW_TOKEN, | ||
use: [apiPlugin], | ||
apiOptions: { | ||
region: process.env.NEXT_PUBLIC_STORYBLOK_REGION, | ||
}, | ||
}); | ||
|
||
export const generateMetadata = () => getMetadata('en', 'website-common'); | ||
|
||
export default function RootLayout({ children }: PropsWithChildren) { | ||
return ( | ||
<html suppressHydrationWarning={true}> | ||
<ContextProviders> | ||
<body>{children}</body> | ||
</ContextProviders> | ||
</html> | ||
<StoryblokProvider> | ||
<html suppressHydrationWarning={true}> | ||
<ContextProviders> | ||
<body>{children}</body> | ||
</ContextProviders> | ||
</html> | ||
</StoryblokProvider> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use client'; | ||
import { SIStoryblokComponentsMap } from '@/types/storyblok/storyblok-util'; | ||
import { apiPlugin, storyblokInit } from '@storyblok/react/rsc'; | ||
|
||
const components: SIStoryblokComponentsMap = {}; | ||
|
||
// Import with component mapping. | ||
// it's necessary to re-initialize here as well, | ||
// as to enable the live editing experience inside | ||
// the Visual Editor you need to initialize the | ||
// lib universally (client + server). | ||
storyblokInit({ | ||
accessToken: process.env.NEXT_PUBLIC_STORYBLOK_PREVIEW_TOKEN, | ||
use: [apiPlugin], | ||
apiOptions: { | ||
region: process.env.NEXT_PUBLIC_STORYBLOK_REGION, | ||
}, | ||
components, | ||
}); | ||
|
||
/** | ||
* Wrapper to ensure client-side loading for hybrid rendering. | ||
*/ | ||
export default function StoryblokProvider({ children }: { children: JSX.Element }) { | ||
return children; | ||
} |