Skip to content

Commit

Permalink
refactor: try different registration method
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdehaven committed Dec 11, 2024
1 parent 39ed179 commit e6ccbd1
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions module/kongponents.nuxt.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineNuxtModule, createResolver, addComponentsDir, useLogger /*, addComponent */ } from '@nuxt/kit'
// import { kebabCase, pascalCase } from 'scule'
import { defineNuxtModule, createResolver, /*addComponentsDir, */ useLogger , addComponent } from '@nuxt/kit'
import { kebabCase, pascalCase } from 'scule'

export interface ModuleOptions {
// Define module options here as needed
Expand All @@ -18,36 +18,37 @@ export default defineNuxtModule<ModuleOptions>({
logger.start('Initializing Kongponents')

// Import all components
// const components = await import(resolver.resolve('../src/components/index.ts'))
const components = await import(resolver.resolve('../src/components/index.ts'))

// let componentCount = 0
let componentCount = 0

// Loop through the imported components
// Object.entries(components).forEach(([name, component]: [string, any]) => {
// if (component) {
// addComponent({
// name,
// filePath: component, // The file path of the component
// global: true,
// kebabName: kebabCase(name),
// pascalName: pascalCase(name),
// })
// // Increment component count
// componentCount++
// }
// })
Object.entries(components).forEach(([name, component]: [string, any]) => {
if (component) {
addComponent({
name,
filePath: component, // The file path of the component
global: true,
kebabName: kebabCase(name),
pascalName: pascalCase(name),
})
// Increment component count
componentCount++
}
})

// logger.success(`Globally registered ${componentCount} components`)
logger.success(`Globally registered ${componentCount} components`)

addComponentsDir({
path: resolver.resolve('../src/components/'),
extensions: ['vue'],
pattern: '**/*.vue',
pathPrefix: false,
prefix: '',
global: true,
})
// 🥲 this doesn't work
// addComponentsDir({
// path: resolver.resolve('../src/components/'),
// extensions: ['vue'],
// pattern: '**/*.vue',
// pathPrefix: false,
// prefix: '',
// global: true,
// })

logger.success('Globally registered all Kongponents')
// logger.success('Globally registered all Kongponents')
},
})

0 comments on commit e6ccbd1

Please sign in to comment.