Skip to content

Commit

Permalink
refactor: try explicit paths
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdehaven committed Dec 11, 2024
1 parent e6ccbd1 commit e0c3b15
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions module/kongponents.nuxt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,31 @@ export default defineNuxtModule<ModuleOptions>({

logger.start('Initializing Kongponents')

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

let componentCount = 0

const allComponents = [
{
name: 'KInput',
filePath: resolver.resolve('../src/components/KInput/KInput.vue'),
},
{
name: 'KButton',
filePath: resolver.resolve('../src/components/KButton/KButton.vue'),
},
]

// 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++
}
})
for (const c of allComponents) {
addComponent({
name: c.name,
filePath: c.filePath,
global: true,
kebabName: kebabCase(c.name),
pascalName: pascalCase(c.name),
})
// Increment component count
componentCount++
}

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

Expand Down

0 comments on commit e0c3b15

Please sign in to comment.