fix(theme): fix copyright link overflow due to excessive length (#486)

This commit is contained in:
pengzhanbo 2025-02-23 02:35:52 +08:00 committed by GitHub
parent f8d32835df
commit 3eaf2908c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 3 deletions

View File

@ -26,7 +26,7 @@ const {
</p>
<p v-if="sourceUrl">
<span>{{ creationText }}</span>
<VPLink :href="sourceUrl" :no-icon="creation === 'original'" data-allow-mismatch>
<VPLink :href="sourceUrl" class="source" :no-icon="creation === 'original'" data-allow-mismatch>
{{ decodeURIComponent(sourceUrl) }}
</VPLink>
</p>
@ -54,6 +54,7 @@ const {
}
.vp-doc .copyright-container p span:first-of-type {
align-self: baseline;
font-weight: bold;
}
@ -63,6 +64,12 @@ const {
color: var(--vp-c-text-2);
transition: color var(--vp-t-color);
}
.vp-doc .copyright-container .source {
flex: 1;
width: 1px;
word-break: break-all;
}
</style>
<style>

View File

@ -52,8 +52,14 @@ export function useCopyright(copyright: ComputedRef<CopyrightFrontmatter>) {
const author = computed(() => resolveAuthor(copyright.value.author, creation.value, contributors.value))
const sourceUrl = computed(() => {
if (creation.value === 'original')
return __VUEPRESS_SSR__ ? route.fullPath : location.href.split('#')[0]
if (creation.value === 'original') {
const url = new URL(__VUEPRESS_SSR__ ? route.fullPath : location.href.split('#')[0])
// When using giscus for comments, the redirect link after
// logging in contains additional parameters.
url.searchParams.delete('giscus')
return url.toString()
}
return copyright.value.source
})