2021-09-27 12:49:36 +00:00
|
|
|
import { resolve } from 'pathe'
|
2023-01-24 15:34:20 +00:00
|
|
|
import { addComponent, addPlugin, defineNuxtModule } from '@nuxt/kit'
|
2021-08-11 21:26:47 +00:00
|
|
|
import { distDir } from '../dirs'
|
2021-07-15 11:28:04 +00:00
|
|
|
|
2022-11-16 02:26:35 +00:00
|
|
|
const components = ['NoScript', 'Link', 'Base', 'Title', 'Meta', 'Style', 'Head', 'Html', 'Body']
|
2022-10-13 15:54:06 +00:00
|
|
|
|
2021-07-15 11:28:04 +00:00
|
|
|
export default defineNuxtModule({
|
2022-01-05 18:09:53 +00:00
|
|
|
meta: {
|
|
|
|
name: 'meta'
|
|
|
|
},
|
2021-07-28 11:48:17 +00:00
|
|
|
setup (options, nuxt) {
|
2022-04-05 14:02:29 +00:00
|
|
|
const runtimeDir = nuxt.options.alias['#head'] || resolve(distDir, 'head/runtime')
|
2021-07-15 11:28:04 +00:00
|
|
|
|
2021-08-11 20:28:38 +00:00
|
|
|
// Transpile @nuxt/meta and @vueuse/head
|
2021-10-12 08:39:06 +00:00
|
|
|
nuxt.options.build.transpile.push('@vueuse/head')
|
2021-08-11 20:28:38 +00:00
|
|
|
|
2022-04-05 14:02:29 +00:00
|
|
|
// Add #head alias
|
|
|
|
nuxt.options.alias['#head'] = runtimeDir
|
2021-07-15 11:28:04 +00:00
|
|
|
|
2022-10-13 15:54:06 +00:00
|
|
|
// Register components
|
|
|
|
const componentsPath = resolve(runtimeDir, 'components')
|
|
|
|
for (const componentName of components) {
|
|
|
|
addComponent({
|
|
|
|
name: componentName,
|
|
|
|
filePath: componentsPath,
|
|
|
|
export: componentName,
|
|
|
|
// kebab case version of these tags is not valid
|
|
|
|
kebabName: componentName
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-07-28 11:48:17 +00:00
|
|
|
// Add library specific plugin
|
|
|
|
addPlugin({ src: resolve(runtimeDir, 'lib/vueuse-head.plugin') })
|
2021-07-15 11:28:04 +00:00
|
|
|
}
|
|
|
|
})
|