0.0.32 • Published 3 years ago

nuxt-storyblok v0.0.32

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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)
  })
  1. The version parameter has been removed. The configuration supports this and thus removes the need for specifying it for every call.
  2. 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.

0.0.30

3 years ago

0.0.31

3 years ago

0.0.32

3 years ago

0.0.27

3 years ago

0.0.28

3 years ago

0.0.29

3 years ago

0.0.21

3 years ago

0.0.22

3 years ago

0.0.23

3 years ago

0.0.24

3 years ago

0.0.25

3 years ago

0.0.26

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.14

3 years ago

0.0.15

3 years ago

0.0.17

3 years ago

0.0.18

3 years ago

1.0.13

5 years ago