feat: add custom VitePress theme with logo patcher

This commit is contained in:
germondai
2026-06-15 13:45:00 +02:00
parent fe7ab0d9da
commit 7155c95776
2 changed files with 33 additions and 0 deletions
@@ -0,0 +1,21 @@
<script setup lang="ts">
import { useRoute } from "vitepress"
import { onMounted, watch } from "vue"
const route = useRoute()
function patch() {
const a = document.querySelector<HTMLAnchorElement>(".VPNavBarTitle a")
if (!a) return
const { protocol, hostname } = window.location
a.href =
hostname === "localhost" || hostname === "127.0.0.1"
? "http://localhost:3000"
: `${protocol}//${hostname.replace(/^docs\./, "")}`
}
onMounted(patch)
watch(() => route.path, patch)
</script>
<template></template>
+12
View File
@@ -0,0 +1,12 @@
import DefaultTheme from "vitepress/theme"
import { h } from "vue"
import LogoPatcher from "./LogoPatcher.vue"
export default {
extends: DefaultTheme,
Layout() {
return h(DefaultTheme.Layout, null, {
"layout-top": () => h(LogoPatcher),
})
},
}