fix: reactivity of CopyrightInfo (#427)
部署到 Cloudflare Pages / deploy (push) Has been cancelled Details

pull/428/head^2
特菈 Dustella 2024-09-19 22:51:57 +08:00 committed by GitHub
parent 6eb309eae3
commit 75cef0f2a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 10 deletions

View File

@ -22,12 +22,12 @@ const { frontmatter } = useData()
<AppearanceToggle> <AppearanceToggle>
<Layout> <Layout>
<template #doc-before> <template #doc-before>
<div class="vp-doc"> <NolebaseHighlightTargetedHeading />
<div class="vp-doc vp-doc-before">
<h1>{{ frontmatter.title }}</h1> <h1>{{ frontmatter.title }}</h1>
<PageInfo /> <PageInfo />
<CopyrightInfo /> <CopyrightInfo />
</div> </div>
<NolebaseHighlightTargetedHeading />
</template> </template>
<template #doc-after> <template #doc-after>
<AppFooter /> <AppFooter />
@ -41,3 +41,10 @@ const { frontmatter } = useData()
</Layout> </Layout>
</AppearanceToggle> </AppearanceToggle>
</template> </template>
<style>
.vp-doc-before + main > div > div > h2:first-of-type {
border-top: unset;
margin-top: 0;
}
</style>

View File

@ -1,5 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { useData } from 'vitepress' import { useData } from 'vitepress'
import { computed } from 'vue'
import type { Node, Trie } from '../plugins/CopyrightLoader.data' import type { Node, Trie } from '../plugins/CopyrightLoader.data'
import { data } from '../plugins/CopyrightLoader.data' import { data } from '../plugins/CopyrightLoader.data'
@ -28,16 +29,16 @@ function searchClosestInTrie(
const paths = useData() const paths = useData()
.page.value.relativePath.replace('.md', '').split('/') .page.value.relativePath.replace('.md', '').split('/')
.filter((item: string) => item !== '') .filter((item: string) => item !== '')
const attrs = searchClosestInTrie(data, paths) const attrs = computed(() => searchClosestInTrie(data, paths))
const frontmatter = useData().frontmatter.value const frontmatter = useData().frontmatter
const originUrlExists = (attrs?.copyright?.url ?? null) != null const originUrlExists = computed(() => (attrs.value?.copyright?.url ?? null) != null)
const originUrl = attrs?.copyright?.url ?? 'javascript:void(0)' const originUrl = computed(() => attrs.value?.copyright?.url ?? 'javascript:void(0)')
const license = attrs?.copyright?.license ?? null const license = computed(() => attrs.value?.copyright?.license ?? null)
const licenseExists = license != null const licenseExists = computed(() => license.value != null)
const licenseUrlExists = (attrs?.copyright?.licenseUrl ?? null) != null const licenseUrlExists = computed(() => (attrs.value?.copyright?.licenseUrl ?? null) != null)
const licenseUrl = attrs?.copyright?.licenseUrl ?? 'javascript:void(0)' const licenseUrl = computed(() => attrs.value?.copyright?.licenseUrl ?? 'javascript:void(0)')
</script> </script>
<template> <template>