Skip to content

Commit

Permalink
feat: bootstrap-vue-3 resolver (#520)
Browse files Browse the repository at this point in the history
  • Loading branch information
VividLemon committed Oct 24, 2022
1 parent 2a120ee commit b58ed85
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/core/resolvers/bootstrap-vue-3.ts
@@ -0,0 +1,38 @@
import type { ComponentResolver } from '../../types'

export interface BootstrapVue3ResolverOptions {
/**
* Auto import for directives.
*
* @default true
*/
directives?: boolean
}

/**
* Resolver for BootstrapVue
*
* @link https://github.com/cdmoro/bootstrap-vue-3
*/
export const BootstrapVue3Resolver = (_options: BootstrapVue3ResolverOptions = {}): Array<ComponentResolver> => {
const options = { directives: true, ..._options }
const resolvers: Array<ComponentResolver> = [{
type: 'component',
resolve: (name) => {
if (name.match(/^B[A-Z]/))
return { name, from: 'bootstrap-vue-3' }
},
}]

if (options.directives) {
resolvers.push({
type: 'directive',
resolve: (name) => {
if (name.match(/^B[A-Z]/))
return { name: `V${name}`, from: 'bootstrap-vue-3' }
},
})
}

return resolvers
}
1 change: 1 addition & 0 deletions src/core/resolvers/index.ts
Expand Up @@ -19,4 +19,5 @@ export * from './arco'
export * from './tdesign'
export * from './layui-vue'
export * from './bootstrap-vue'
export * from './bootstrap-vue-3'
export * from './ionic'

0 comments on commit b58ed85

Please sign in to comment.