mirror of
https://github.com/pengzhanbo/vuepress-theme-plume.git
synced 2026-04-23 10:58:13 +08:00
fix(theme): fix multiple icon provider (#826)
This commit is contained in:
parent
48970dd559
commit
85fc35f119
@ -29,6 +29,17 @@ const type = computed(() => {
|
||||
return 'svg'
|
||||
}
|
||||
|
||||
if (typeof name === 'string') {
|
||||
if (name.startsWith('iconify'))
|
||||
return 'iconify'
|
||||
|
||||
if (name.startsWith('iconfont'))
|
||||
return 'iconfont'
|
||||
|
||||
if (name.startsWith('fontawesome'))
|
||||
return 'fontawesome'
|
||||
}
|
||||
|
||||
const _provider = provider || __MD_POWER_ICON_PROVIDER__
|
||||
if (_provider === 'iconfont' || _provider === 'fontawesome') {
|
||||
return _provider
|
||||
@ -55,7 +66,7 @@ const rect = computed(() => {
|
||||
return { width, height: height || width }
|
||||
})
|
||||
const binding = computed(() => ({
|
||||
name: name as string,
|
||||
name: (name as string).replace(/^(iconify|iconfont|fontawesome)\s+/, ''),
|
||||
color,
|
||||
size: rect.value,
|
||||
prefix: __MD_POWER_ICON_PREFIX__ as any,
|
||||
|
||||
@ -30,7 +30,7 @@ type IconDataMap = Record<string, IconData>
|
||||
const ICON_REGEXP = /<(?:VP)?(Icon|Card|LinkCard|Button)([^>]*)>/g
|
||||
const ICON_NAME_REGEXP = /(?:name|icon|suffix-icon)="([^"]+)"/
|
||||
const URL_CONTENT_REGEXP = /(url\([\s\S]+\))/
|
||||
const ICONIFY_NAME = /^[\w-]+:[\w-]+$/
|
||||
const ICONIFY_NAME = /^(?:iconify\s+)?[\w-]+:[\w-]+$/
|
||||
|
||||
const JS_FILENAME = 'internal/iconify.js'
|
||||
const CSS_FILENAME = 'internal/iconify.css'
|
||||
@ -148,6 +148,7 @@ function isIconify(icon: unknown): icon is string {
|
||||
}
|
||||
|
||||
function withPrefix(icon: string, prefix?: string): string {
|
||||
icon = icon.replace(/^iconify /, '')
|
||||
if (!prefix)
|
||||
return icon
|
||||
return icon.includes(':') ? icon : `${prefix}:${icon}`
|
||||
@ -166,7 +167,7 @@ function getIconsWithPage(page: Page, { provider = 'iconify', prefix }: IconOpti
|
||||
|
||||
const addIcon = (icon: unknown): void => {
|
||||
if (icon && isIconify(icon) && (provider === 'iconify' || icon.startsWith('iconify'))) {
|
||||
list.push(withPrefix(icon.replace(/^iconify /, ''), prefix))
|
||||
list.push(withPrefix(icon, prefix))
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,7 +241,7 @@ function getIconWithThemeConfig(options: ThemeOptions, { provider = 'iconify', p
|
||||
|
||||
const addIcon = (icon: unknown): string | void => {
|
||||
if (icon && isIconify(icon) && (provider === 'iconify' || icon.startsWith('iconify'))) {
|
||||
return withPrefix(icon.replace(/^iconify /, ''), prefix)
|
||||
return withPrefix(icon, prefix)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user