Skip to content
Permalink
Browse files
feat(theme): allow specifying common alt for logo (#1451)
Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
  • Loading branch information
7nohe and brc-dd committed Oct 13, 2022
1 parent 41a519c commit 55688a87e3baa38d0e0a37a6eba0039484416875
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
@@ -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 -------------------------------------------------------------------

0 comments on commit 55688a8

Please sign in to comment.