fix: hydration completed but contains mismatches
This commit is contained in:
parent
73314557d2
commit
ae4496d591
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
yarn commitlint --edit $1
|
||||
npx commitlint --edit $1
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
yarn lint-staged
|
||||
npx lint-staged
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import { Icon as OfflineIcon } from '@iconify/vue/offline'
|
||||
import { ClientOnly } from '@vuepress/client'
|
||||
import type { CSSProperties } from 'vue'
|
||||
import { computed, toRefs } from 'vue'
|
||||
import { useIconify } from '../composables/iconify.js'
|
||||
@ -42,16 +43,18 @@ declare const __VUEPRESS_PLUGIN_ICONIFY_DEFAULT_COLOR__: string
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span v-if="!loaded" class="vp-iconify" :style="iconStyle"></span>
|
||||
<OfflineIcon
|
||||
v-else-if="icon"
|
||||
:icon="icon"
|
||||
class="vp-iconify"
|
||||
:style="iconStyle"
|
||||
/>
|
||||
<span v-else class="vp-iconify" :style="{ ...iconStyle, fontSize: size }">
|
||||
{{ props.name }}
|
||||
</span>
|
||||
<ClientOnly>
|
||||
<span v-if="!loaded" class="vp-iconify" :style="iconStyle"></span>
|
||||
<OfflineIcon
|
||||
v-else-if="icon"
|
||||
:icon="icon"
|
||||
class="vp-iconify"
|
||||
:style="iconStyle"
|
||||
/>
|
||||
<span v-else class="vp-iconify" :style="{ ...iconStyle, fontSize: size }">
|
||||
{{ props.name }}
|
||||
</span>
|
||||
</ClientOnly>
|
||||
</template>
|
||||
<style scoped>
|
||||
.vp-iconify {
|
||||
|
||||
@ -13,10 +13,14 @@ export const useIconify = (name: ComputedRef<string> | Ref<string>) => {
|
||||
if (icon.value) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
loaded.value = false
|
||||
iconCache.value[name.value] = await loadIcon(name.value)
|
||||
} finally {
|
||||
if (!__VUEPRESS_SSR__) {
|
||||
try {
|
||||
loaded.value = false
|
||||
iconCache.value[name.value] = await loadIcon(name.value)
|
||||
} finally {
|
||||
loaded.value = true
|
||||
}
|
||||
} else {
|
||||
loaded.value = true
|
||||
}
|
||||
}
|
||||
|
||||
2
packages/plugin-iconify/src/shim.d.ts
vendored
2
packages/plugin-iconify/src/shim.d.ts
vendored
@ -2,3 +2,5 @@ declare module '*.vue' {
|
||||
const comp: any
|
||||
export default comp
|
||||
}
|
||||
|
||||
declare const __VUEPRESS_SSR__: boolean
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user