Skip to content

Commit 6c89943

Browse files
committedDec 31, 2023
feat(theme): allow specifying rel and target in logoLink
closes #3264 closes #3271
1 parent 2c4f271 commit 6c89943

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed
 

‎src/client/theme-default/components/VPNavBarTitle.vue

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script setup lang="ts">
2+
import { computed } from 'vue'
23
import { useData } from '../composables/data'
34
import { useLangs } from '../composables/langs'
45
import { useSidebar } from '../composables/sidebar'
@@ -8,11 +9,34 @@ import VPImage from './VPImage.vue'
89
const { site, theme } = useData()
910
const { hasSidebar } = useSidebar()
1011
const { currentLang } = useLangs()
12+
13+
const link = computed(() =>
14+
typeof theme.value.logoLink === 'string'
15+
? theme.value.logoLink
16+
: theme.value.logoLink?.link
17+
)
18+
19+
const rel = computed(() =>
20+
typeof theme.value.logoLink === 'string'
21+
? undefined
22+
: theme.value.logoLink?.rel
23+
)
24+
25+
const target = computed(() =>
26+
typeof theme.value.logoLink === 'string'
27+
? undefined
28+
: theme.value.logoLink?.target
29+
)
1130
</script>
1231

1332
<template>
1433
<div class="VPNavBarTitle" :class="{ 'has-sidebar': hasSidebar }">
15-
<a class="title" :href="theme.logoLink ?? normalizeLink(currentLang.link)">
34+
<a
35+
class="title"
36+
:href="link ?? normalizeLink(currentLang.link)"
37+
:rel="rel"
38+
:target="target"
39+
>
1640
<slot name="nav-bar-title-before" />
1741
<VPImage v-if="theme.logo" class="logo" :image="theme.logo" />
1842
<template v-if="theme.siteTitle">{{ theme.siteTitle }}</template>

‎types/default-theme.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export namespace DefaultTheme {
2020
/**
2121
* Overrides the link of the site logo.
2222
*/
23-
logoLink?: string
23+
logoLink?: string | { link?: string; rel?: string; target?: string }
2424

2525
/**
2626
* Custom site title in navbar. If the value is undefined,
@@ -174,8 +174,8 @@ export namespace DefaultTheme {
174174
* RegExp object here because it isn't serializable
175175
*/
176176
activeMatch?: string
177-
target?: string
178177
rel?: string
178+
target?: string
179179
}
180180

181181
export interface NavItemChildren {

0 commit comments

Comments
 (0)
Please sign in to comment.