Render the header logo without IPX
This commit is contained in:
1 parent
9e328f859d
commit
f6e2833131
1 file changed
+33
@@ -0,0 +1,33 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
// Override of Docus's AppHeaderLogo. The stock one renders UColorModeImage,
|
||||||
|
// which goes through NuxtImg/IPX: the prerendered /_ipx/_/img/logo.svg gets
|
||||||
|
// recorded as `text/plain` (and the same for the SVG's own response in
|
||||||
|
// `nuxt preview`), so browsers refuse to draw it inside an <img>. An SVG has
|
||||||
|
// nothing to optimize anyway, so plain <img> tags point straight at it.
|
||||||
|
const appConfig = useAppConfig()
|
||||||
|
const { hasLogo, headerLightUrl, headerDarkUrl, contextMenuItems } = useLogoAssets()
|
||||||
|
const alt = computed(() => appConfig.header?.logo?.alt || appConfig.header?.title)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UContextMenu
|
||||||
|
v-if="hasLogo"
|
||||||
|
:items="contextMenuItems"
|
||||||
|
>
|
||||||
|
<span class="contents">
|
||||||
|
<img
|
||||||
|
:src="headerLightUrl"
|
||||||
|
:alt="alt"
|
||||||
|
:class="['dark:hidden h-6 w-auto shrink-0', appConfig.header?.logo?.class]"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
:src="headerDarkUrl"
|
||||||
|
:alt="alt"
|
||||||
|
:class="['hidden dark:block h-6 w-auto shrink-0', appConfig.header?.logo?.class]"
|
||||||
|
>
|
||||||
|
</span>
|
||||||
|
</UContextMenu>
|
||||||
|
<span v-else>
|
||||||
|
{{ appConfig.header?.title || '{appConfig.header.title}' }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
Reference in new issue
Block a user