mirror of
https://github.com/germondai/trawl.git
synced 2026-08-17 12:11:23 +02:00
feat: add custom VitePress theme with logo patcher
This commit is contained in:
@@ -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>
|
||||
@@ -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),
|
||||
})
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user