Skip to content

Commit

Permalink
feat(theme): allow specifying rel and target in logoLink
Browse files Browse the repository at this point in the history
closes #3264
closes #3271
  • Loading branch information
brc-dd committed Dec 31, 2023
1 parent 2c4f271 commit 6c89943
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
26 changes: 25 additions & 1 deletion src/client/theme-default/components/VPNavBarTitle.vue
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useData } from '../composables/data'
import { useLangs } from '../composables/langs'
import { useSidebar } from '../composables/sidebar'
Expand All @@ -8,11 +9,34 @@ import VPImage from './VPImage.vue'
const { site, theme } = useData()
const { hasSidebar } = useSidebar()
const { currentLang } = useLangs()
const link = computed(() =>
typeof theme.value.logoLink === 'string'
? theme.value.logoLink
: theme.value.logoLink?.link
)
const rel = computed(() =>
typeof theme.value.logoLink === 'string'
? undefined
: theme.value.logoLink?.rel
)
const target = computed(() =>
typeof theme.value.logoLink === 'string'
? undefined
: theme.value.logoLink?.target
)
</script>

<template>
<div class="VPNavBarTitle" :class="{ 'has-sidebar': hasSidebar }">
<a class="title" :href="theme.logoLink ?? normalizeLink(currentLang.link)">
<a
class="title"
:href="link ?? normalizeLink(currentLang.link)"
:rel="rel"
:target="target"
>
<slot name="nav-bar-title-before" />
<VPImage v-if="theme.logo" class="logo" :image="theme.logo" />
<template v-if="theme.siteTitle">{{ theme.siteTitle }}</template>
Expand Down
4 changes: 2 additions & 2 deletions types/default-theme.d.ts
Expand Up @@ -20,7 +20,7 @@ export namespace DefaultTheme {
/**
* Overrides the link of the site logo.
*/
logoLink?: string
logoLink?: string | { link?: string; rel?: string; target?: string }

/**
* Custom site title in navbar. If the value is undefined,
Expand Down Expand Up @@ -174,8 +174,8 @@ export namespace DefaultTheme {
* RegExp object here because it isn't serializable
*/
activeMatch?: string
target?: string
rel?: string
target?: string
}

export interface NavItemChildren {
Expand Down

0 comments on commit 6c89943

Please sign in to comment.