Skip to content

Commit

Permalink
Merge pull request #333 from markus-gx/feat/nuxt-devtools
Browse files Browse the repository at this point in the history
Nuxt Devtools integration
  • Loading branch information
alexjoverm authored Apr 6, 2023
2 parents 6186c92 + 44a5879 commit 6a85731
Show file tree
Hide file tree
Showing 5 changed files with 4,881 additions and 716 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@ export default defineNuxtConfig({
#### Options

When you initialize the module, you can pass all [_@storyblok/vue_ options](https://github.com/storyblok/storyblok-vue#storyblok-api) plus a `bridge` option explained in our [JS SDK Storyblok bridge section](https://github.com/storyblok/storyblok-js#storyblok-bridge).
If you want to use Storyblok inside `nuxt-devtools` you can use the option `devtools`, if enabled, make sure to have installed the @nuxt/devtools module and enable it on your nuxt config.

```js
// Defaults
["@storyblok/nuxt", {
{
accessToken: "<your-access-token>",
bridge: true,
devtools: true,
apiOptions: {}, // storyblok-js-client options
}
}]
Expand Down
17 changes: 17 additions & 0 deletions lib/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface ModuleOptions {
accessToken: string,
usePlugin: boolean,
bridge: boolean, // storyblok bridge on/off
devtools: boolean, // enable nuxt/devtools integration
apiOptions: any, // storyblok-js-client options
}

Expand All @@ -23,6 +24,7 @@ export default defineNuxtModule<ModuleOptions>({
accessToken: '',
usePlugin: true,
bridge: true,
devtools: false,
apiOptions: {},
},
setup(options, nuxt) {
Expand Down Expand Up @@ -59,5 +61,20 @@ export default defineNuxtModule<ModuleOptions>({
addImports({ name, as: name, from: "@storyblok/vue" });
}
addImportsDir(resolver.resolve("./runtime/composables"));

if (options.devtools) {
// @ts-expect-error - private API
nuxt.hook('devtools:customTabs', (iframeTabs) => {
iframeTabs.push({
name: 'storyblok',
title: 'Storyblok',
icon: 'i-logos-storyblok-icon',
view: {
type: 'iframe',
src: 'https://app.storyblok.com/#!/me/spaces/'
}
})
})
}
}
});
Loading

0 comments on commit 6a85731

Please sign in to comment.