Skip to content

Commit

Permalink
feat(kit): support prepend option for addComponentsDir (#24309)
Browse files Browse the repository at this point in the history
  • Loading branch information
sadeghbarati authored and manniL committed Dec 11, 2023
1 parent 03600a1 commit 04fbb1e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/kit/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { logger } from './logger'
*
* Requires Nuxt 2.13+
*/
export async function addComponentsDir (dir: ComponentsDir) {
export async function addComponentsDir (dir: ComponentsDir, opts: { prepend?: boolean } = {}) {
const nuxt = useNuxt()
await assertNuxtCompatibility({ nuxt: '>=2.13' }, nuxt)
nuxt.options.components = nuxt.options.components || []
dir.priority ||= 0
nuxt.hook('components:dirs', (dirs) => { dirs.push(dir) })
nuxt.hook('components:dirs', (dirs) => { dirs[opts.prepend ? 'unshift' : 'push'](dir) })
}

export type AddComponentOptions = { name: string, filePath: string } & Partial<Exclude<Component,
Expand Down

0 comments on commit 04fbb1e

Please sign in to comment.