@storyblok/nuxt 4.0.0 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -46,13 +46,13 @@ npm install @storyblok/nuxt
46
46
  # yarn add @storyblok/nuxt
47
47
  ```
48
48
 
49
- Add following code to buildModules section of `nuxt.config.js` and replace the accessToken with API token from Storyblok space.
49
+ Add following code to modules section of `nuxt.config.js` and replace the accessToken with API token from Storyblok space.
50
50
 
51
51
  ```js
52
52
  import { defineNuxtConfig } from "nuxt";
53
53
 
54
54
  export default defineNuxtConfig({
55
- buildModules: [
55
+ modules: [
56
56
  ["@storyblok/nuxt", { accessToken: "<your-access-token>" }]
57
57
  // ...
58
58
  ]
@@ -65,7 +65,7 @@ You can also use the `storyblok` config if you prefer:
65
65
  import { defineNuxtConfig } from "nuxt";
66
66
 
67
67
  export default defineNuxtConfig({
68
- buildModules: ["@storyblok/nuxt"],
68
+ modules: ["@storyblok/nuxt"],
69
69
  storyblok: {
70
70
  accessToken: "<your-access-token>"
71
71
  }
@@ -102,7 +102,7 @@ To link your Vue components to their equivalent you created in Storyblok:
102
102
  <div v-editable="blok" / >
103
103
  ```
104
104
 
105
- - Finally, use `<StoryblokComponent>` which available globally in the Nuxt app:
105
+ - Finally, use `<StoryblokComponent>` which is available globally in the Nuxt app:
106
106
 
107
107
  ```html
108
108
  <StoryblokComponent :blok="blok" />
@@ -114,7 +114,7 @@ To link your Vue components to their equivalent you created in Storyblok:
114
114
 
115
115
  #### Composition API
116
116
 
117
- The simplest way is by using the `useStoryblok` one-liner composable (it's autoimported):
117
+ The simplest way is by using the `useStoryblok` one-liner composable (it's autoimported) and passing as a first parameter a name of your content page from Storyblok (in this case, our content page name is `vue`, by default you get a content page named `home`):
118
118
 
119
119
  ```html
120
120
  <script setup>
@@ -147,6 +147,20 @@ Which is the short-hand equivalent to using `useStoryblokApi` and `useStoryblokB
147
147
  </template>
148
148
  ```
149
149
 
150
+ #### Rendering Rich Text
151
+
152
+ You can easily render rich text by using the `renderRichText` function that comes with `@storyblok/nuxt` and a Vue computed property:
153
+
154
+ ```html
155
+ <template>
156
+ <div v-html="articleContent"></div>
157
+ </template>
158
+
159
+ <script setup>
160
+ const articleContent = computed(() => renderRichText(blok.articleContent));
161
+ </script>
162
+ ```
163
+
150
164
  ### API
151
165
 
152
166
  #### useStoryblok(slug, apiOptions, bridgeOptions)
@@ -0,0 +1,5 @@
1
+ module.exports = function(...args) {
2
+ return import('./module.mjs').then(m => m.default.call(this, ...args))
3
+ }
4
+ const _meta = module.exports.meta = require('./module.json')
5
+ module.exports.getMeta = () => Promise.resolve(_meta)
@@ -0,0 +1,42 @@
1
+ import { resolve } from 'path';
2
+ import { fileURLToPath } from 'url';
3
+ import { defineNuxtModule, addComponentsDir, addPlugin, addAutoImport } from '@nuxt/kit';
4
+
5
+ // -- Unbuild CommonJS Shims --
6
+ import __cjs_url__ from 'url';
7
+ import __cjs_path__ from 'path';
8
+ import __cjs_mod__ from 'module';
9
+ const __filename = __cjs_url__.fileURLToPath(import.meta.url);
10
+ const __dirname = __cjs_path__.dirname(__filename);
11
+ const require = __cjs_mod__.createRequire(import.meta.url);
12
+
13
+
14
+ var module = defineNuxtModule({
15
+ meta: {
16
+ name: "@storyblok/nuxt-beta",
17
+ configKey: "storyblok"
18
+ },
19
+ defaults: {},
20
+ setup(options, nuxt) {
21
+ const axiosIndex = nuxt.options.build.transpile.indexOf("axios");
22
+ if (axiosIndex !== -1) {
23
+ nuxt.options.build.transpile.splice(axiosIndex, 1);
24
+ }
25
+ nuxt.options.vite.optimizeDeps.include = nuxt.options.vite.optimizeDeps.include || [];
26
+ nuxt.options.vite.optimizeDeps.include.push("axios");
27
+ addComponentsDir({ path: "~/storyblok", global: true, pathPrefix: false });
28
+ const runtimeDir = fileURLToPath(new URL("./runtime", import.meta.url));
29
+ nuxt.options.build.transpile.push(runtimeDir);
30
+ nuxt.options.runtimeConfig.public.storyblok = options;
31
+ addPlugin(resolve(__dirname, "runtime", `./plugin`));
32
+ const names = [
33
+ "useStoryblok",
34
+ "useStoryblokApi",
35
+ "useStoryblokBridge",
36
+ "renderRichText"
37
+ ];
38
+ names.forEach((name) => addAutoImport({ name, as: name, from: "@storyblok/vue" }));
39
+ }
40
+ });
41
+
42
+ export { module as default };
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "@storyblok/nuxt-beta",
3
+ "configKey": "storyblok",
4
+ "version": "0.0.1"
5
+ }
@@ -0,0 +1,42 @@
1
+ import { resolve } from 'path';
2
+ import { fileURLToPath } from 'url';
3
+ import { defineNuxtModule, addComponentsDir, addPlugin, addAutoImport } from '@nuxt/kit';
4
+
5
+ // -- Unbuild CommonJS Shims --
6
+ import __cjs_url__ from 'url';
7
+ import __cjs_path__ from 'path';
8
+ import __cjs_mod__ from 'module';
9
+ const __filename = __cjs_url__.fileURLToPath(import.meta.url);
10
+ const __dirname = __cjs_path__.dirname(__filename);
11
+ const require = __cjs_mod__.createRequire(import.meta.url);
12
+
13
+
14
+ const module = defineNuxtModule({
15
+ meta: {
16
+ name: "@storyblok/nuxt-beta",
17
+ configKey: "storyblok"
18
+ },
19
+ defaults: {},
20
+ setup(options, nuxt) {
21
+ const axiosIndex = nuxt.options.build.transpile.indexOf("axios");
22
+ if (axiosIndex !== -1) {
23
+ nuxt.options.build.transpile.splice(axiosIndex, 1);
24
+ }
25
+ nuxt.options.vite.optimizeDeps.include = nuxt.options.vite.optimizeDeps.include || [];
26
+ nuxt.options.vite.optimizeDeps.include.push("axios");
27
+ addComponentsDir({ path: "~/storyblok", global: true, pathPrefix: false });
28
+ const runtimeDir = fileURLToPath(new URL("./runtime", import.meta.url));
29
+ nuxt.options.build.transpile.push(runtimeDir);
30
+ nuxt.options.runtimeConfig.public.storyblok = options;
31
+ addPlugin(resolve(__dirname, "runtime", `./plugin`));
32
+ const names = [
33
+ "useStoryblok",
34
+ "useStoryblokApi",
35
+ "useStoryblokBridge",
36
+ "renderRichText"
37
+ ];
38
+ names.forEach((name) => addAutoImport({ name, as: name, from: "@storyblok/vue" }));
39
+ }
40
+ });
41
+
42
+ export { module as default };
@@ -0,0 +1,2 @@
1
+ declare var _default: any;
2
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import { StoryblokVue, apiPlugin } from "@storyblok/vue";
2
+ import { defineNuxtPlugin, useRuntimeConfig } from "#app";
3
+
4
+ export default defineNuxtPlugin(({ vueApp }) => {
5
+ const { storyblok } = useRuntimeConfig();
6
+ vueApp.use(StoryblokVue, { ...storyblok, use: [apiPlugin] });
7
+ });
@@ -0,0 +1,6 @@
1
+
2
+ import { } from './module'
3
+
4
+
5
+
6
+ export { default } from './module'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyblok/nuxt",
3
- "version": "4.0.0",
3
+ "version": "4.1.1",
4
4
  "description": "Storyblok Nuxt.js module",
5
5
  "main": "./src/module.js",
6
6
  "module": "./src/module.js",
@@ -11,7 +11,8 @@
11
11
  }
12
12
  },
13
13
  "files": [
14
- "src"
14
+ "src",
15
+ "dist"
15
16
  ],
16
17
  "repository": "https://github.com/storyblok/storyblok-nuxt",
17
18
  "scripts": {
@@ -27,12 +28,12 @@
27
28
  },
28
29
  "dependencies": {
29
30
  "@nuxt/kit": "^3.0.0-rc.2",
30
- "@storyblok/vue": "^6.0.3"
31
+ "@storyblok/vue": "^6.2.0"
31
32
  },
32
33
  "devDependencies": {
33
34
  "@babel/core": "^7.15.0",
34
35
  "@nuxt/module-builder": "latest",
35
- "babel-jest": "^26.6.3",
36
+ "babel-jest": "^28.1.3",
36
37
  "cypress": "^8.3.0",
37
38
  "eslint-plugin-cypress": "^2.12.1",
38
39
  "jest": "^26.6.3",
package/src/module.js CHANGED
@@ -36,7 +36,12 @@ export default defineNuxtModule({
36
36
  addPlugin(resolve(__dirname, "runtime", `./plugin`));
37
37
 
38
38
  // Autoimports
39
- const names = ["useStoryblok", "useStoryblokApi", "useStoryblokBridge"];
39
+ const names = [
40
+ "useStoryblok",
41
+ "useStoryblokApi",
42
+ "useStoryblokBridge",
43
+ "renderRichText"
44
+ ];
40
45
  names.forEach((name) =>
41
46
  addAutoImport({ name, as: name, from: "@storyblok/vue" })
42
47
  );