feat(theme): allow specifying common alt for logo (#1451)

Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
pull/1479/head
Urata Daiki 2 years ago committed by GitHub
parent 41a519cc77
commit 55688a87e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,6 +4,7 @@ import { withBase } from 'vitepress'
defineProps<{
image: DefaultTheme.ThemeableImage
alt?: string
}>()
</script>
@ -20,11 +21,29 @@ export default {
class="VPImage"
v-bind="typeof image === 'string' ? $attrs : { ...image, ...$attrs }"
:src="withBase(typeof image === 'string' ? image : image.src)"
:alt="typeof image === 'string' ? '' : (image.alt || '')"
:alt="alt ?? (typeof image === 'string' ? '' : image.alt || '')"
/>
<template v-else>
<VPImage class="dark" :image="image.dark" v-bind="$attrs" />
<VPImage class="light" :image="image.light" v-bind="$attrs" />
<VPImage
class="dark"
:image="image.dark"
:alt="
typeof image.dark === 'string'
? image.alt
: image.dark.alt || image.alt
"
v-bind="$attrs"
/>
<VPImage
class="light"
:image="image.light"
:alt="
typeof image.light === 'string'
? image.alt
: image.light.alt || image.alt
"
v-bind="$attrs"
/>
</template>
</template>
</template>

@ -116,7 +116,9 @@ export namespace DefaultTheme {
// image -----------------------------------------------------------------------
export type ThemeableImage = Image | { light: Image; dark: Image }
export type ThemeableImage =
| Image
| { light: Image; dark: Image; alt?: string }
export type Image = string | { src: string; alt?: string }
// sidebar -------------------------------------------------------------------

Loading…
Cancel
Save