-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#693): initial druxt-menu update for @nuxt/kit
- Loading branch information
Showing
4 changed files
with
85 additions
and
86 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
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
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,81 @@ | ||
import { addPluginTemplate, defineNuxtModule, installModule } from '@nuxt/kit' | ||
import { join, resolve } from 'path' | ||
// import DruxtMenuStorybook from '../nuxtStorybook' | ||
|
||
/** | ||
* The Nuxt.js module function. | ||
* | ||
* - Adds Nuxt plugin. | ||
* - Adds Vuex store. | ||
* - Adds Nuxt Storybook integration. | ||
* | ||
* The module function should not be used directly, but rather installed via your Nuxt configuration file. | ||
* | ||
* Options are set on the root level `druxt` Nuxt config object. | ||
* | ||
* @example @lang js | ||
* // `nuxt.config.js` | ||
* module.exports = { | ||
* modules: [ | ||
* 'druxt-menu' | ||
* ], | ||
* druxt: { | ||
* baseUrl: 'https://demo-api.druxtjs.org' | ||
* } | ||
* } | ||
* | ||
* @param {object} moduleOptions - Module options object. | ||
*/ | ||
const DruxtMenuNuxtModule = defineNuxtModule({ | ||
meta: { | ||
name: 'druxt-menu', | ||
}, | ||
defaults: { | ||
baseUrl: '', | ||
endpoint: '/jsonapi' | ||
}, | ||
|
||
async setup(moduleOptions, nuxt) { | ||
// Set default options. | ||
const options = { | ||
baseUrl: moduleOptions.baseUrl, | ||
...nuxt.options?.druxt || {}, | ||
menu: { | ||
jsonApiMenuItems: true, | ||
...nuxt.options?.druxt?.menu, | ||
...moduleOptions, | ||
} | ||
} | ||
|
||
// Add dependant modules. | ||
await installModule('druxt/nuxt', options) | ||
|
||
// Register components directories. | ||
nuxt.hook('components:dirs', dirs => { | ||
dirs.push({ path: join(__dirname, '../dist/components') }) | ||
dirs.push({ path: join(__dirname, '../dist/components/blocks') }) | ||
}) | ||
|
||
// Add plugin. | ||
addPluginTemplate({ | ||
src: resolve(__dirname, '../templates/plugin.js'), | ||
fileName: 'druxt-menu.js', | ||
options | ||
}) | ||
|
||
// Add Vuex plugin. | ||
addPluginTemplate({ | ||
src: resolve(__dirname, '../templates/store.js'), | ||
fileName: 'store/druxt-menu.js', | ||
options | ||
}) | ||
|
||
// Nuxt Storybook. | ||
// @TODO - @nuxt/kit and @nuxt/storybook aren't compatible. | ||
// this.nuxt.hook('storybook:config', async ({ stories }) => { | ||
// await DruxtMenuStorybook.call(this, { stories }) | ||
// }) | ||
} | ||
}) | ||
|
||
export default DruxtMenuNuxtModule |
This file was deleted.
Oops, something went wrong.