Skip to content

Commit

Permalink
feat(#693): initial druxt-breadcrumb update for @nuxt/kit
Browse files Browse the repository at this point in the history
  • Loading branch information
Decipher committed Aug 8, 2024
1 parent 3da0e91 commit 7c8ac00
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 72 deletions.
5 changes: 4 additions & 1 deletion packages/breadcrumb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,18 @@
"require": "./dist/druxt-breadcrumb.ssr.js",
"import": "./dist/druxt-breadcrumb.esm.js"
},
"./components/*": "./dist/components/*"
"./components/*": "./dist/components/*",
"./nuxt": "./nuxt/index.js"
},
"main": "dist/druxt-breadcrumb.ssr.js",
"module": "dist/druxt-breadcrumb.esm.js",
"files": [
"dist",
"nuxt",
"templates"
],
"dependencies": {
"@nuxt/kit": "^3.12.2",
"druxt": "^0.22.0",
"druxt-blocks": "^0.17.1",
"druxt-router": "^0.29.1"
Expand Down
14 changes: 0 additions & 14 deletions packages/breadcrumb/src/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
import { DruxtBreadcrumbModule } from './nuxtModule'

/**
* The Nuxt.js module function.
*
* Installs the module functionality in a Nuxt.js frontend.
*
* @type {Function}
* @exports default
* @name DruxtBreadcrumbModule
* @see {@link ./module|DruxtBreadcrumbModule}
*/
export default DruxtBreadcrumbModule

/**
* Vue.js Mixin.
*
Expand Down
67 changes: 67 additions & 0 deletions packages/breadcrumb/src/nuxt/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { defineNuxtModule, installModule } from '@nuxt/kit'
import { join } from 'path'

/**
* The Nuxt.js module function.
*
* - Adds the Vue.js components to the Nuxt.js frontend.
*
* The module function should not be used directly, but rather installed via yout Nuxt.js configuration file.
*
* Options are set on the root level `druxt` Nuxt.js config object.
*
* @example <caption>nuxt.config.js</caption> @lang js
* module.exports = {
* modules: [
* 'druxt-breadcrumb'
* ],
* druxt: {
* baseUrl: 'https://example.com'
* }
* }
*
* @param {object} moduleOptions - Nuxt.js module options object.
*/
const DruxtBreadcrumbModule = defineNuxtModule({
meta: {
name: 'druxt-breadcrumb',
},
defaults: {
baseUrl: '',
endpoint: '/jsonapi'
},

async setup(moduleOptions, nuxt) {
// Set default options.
const options = {
baseUrl: moduleOptions.baseUrl,
...nuxt.options?.druxt || {},
breadcrumb: {
...nuxt.options?.druxt?.breadcrumb,
...moduleOptions,
}
}

// Add dependent module.
await installModule('druxt/nuxt', options, nuxt)
await installModule('druxt-router/nuxt', options, nuxt)

// Register components directories.
nuxt.hook('components:dirs', dirs => {
dirs.push({ path: join(__dirname, '../dist/components') })
dirs.push({ path: join(__dirname, '../dist/components/blocks') })
})

// Nuxt Storybook.
// @TODO - @nuxt/kit and @nuxt/storybook aren't compatible.
// nuxt.hook('storybook:config', ({ stories }) => {
// addTemplate({
// src: resolve(__dirname, '../templates/druxt-breadcrumb.stories.js'),
// fileName: 'stories/druxt-breadcrumb.stories.js',
// })
// stories.push(resolve(nuxt.options.buildDir, './stories/druxt-breadcrumb.stories.js'))
// })
}
})

export default DruxtBreadcrumbModule
57 changes: 0 additions & 57 deletions packages/breadcrumb/src/nuxtModule.js

This file was deleted.

0 comments on commit 7c8ac00

Please sign in to comment.