nuxt-storyblok v0.0.32
Nuxt Storyblok Package
This package exists primarily because of the setTimeout()
throttle that exists in the official Storyblok package and which causes a stack overflow. It acts as a replacement of the official package and manages per-process memory cache of all responses.
We also use an express proxy instead of direct calls to handle caching and possibly live in case Storyblok goes down.
A low cache TTL is used because all content is actually always looked up via Storyblok's CDN (Cloudfront). Using a low TTL also removes the need for cleaning the cache on publish. Let clients know that there can be a delay up to cacheTTL
seconds after publishing content to production.
Because we unlike the official repository don't want to modify axios behaviour, all parameters have to be passed a params
to the second argument of get()
The official library:
this.$storyapi.get('cdn/stories', {
version: 'draft',
starts_with: 'news/'
}).then((res) => {
console.log(res.data.stories)
})
Our library:
this.$storyapi.get('cdn/stories', {
params: {
starts_with: 'news/'
}
}).then((res) => {
console.log(res.data.stories)
})
- The
version
parameter has been removed. The configuration supports this and thus removes the need for specifying it for every call. - There is a key
params
that indicates we want to send parameters.
Enable this module in your project by adding it to your nuxt.config.js
:
modules: [
// ...
// ... other modules exist here as well
// ...
[
"@madepeople/nuxt-storyblok",
{
// 'draft' or 'published', limited by the token
version: "published",
// Which token to use, from your storyblok account under Settings / API Keys
token: "",
}
],
],
See the module.js file for all options and their explanations.
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago