fix(theme): incorrect displaying external link icon (#760)
This commit is contained in:
parent
2bb5c0e2d5
commit
e0b972c3cb
@ -44,7 +44,6 @@ export function linksPlugin(md: Markdown): void {
|
||||
// convert starting tag of internal link
|
||||
hasOpenInternalLink = true
|
||||
token.tag = internalTag
|
||||
token.attrJoin(':no-icon', 'true')
|
||||
|
||||
const matched = hrefLink.match(/^([^#?]*?(?:\/|\.md|\.html))([#?].*)?$/)
|
||||
|
||||
|
||||
@ -116,7 +116,7 @@ const coverStyles = computed(() => {
|
||||
<div v-if="categoryList.length" class="category-list">
|
||||
<span class="icon vpi-folder" />
|
||||
<template v-for="(cate, i) in categoryList" :key="i">
|
||||
<VPLink :href="categoriesLink ? `${categoriesLink.link}?id=${cate.id}` : undefined">
|
||||
<VPLink :href="categoriesLink ? `${categoriesLink.link}?id=${cate.id}` : undefined" no-icon>
|
||||
{{ cate.name }}
|
||||
</VPLink>
|
||||
<span v-if="i !== categoryList.length - 1">/</span>
|
||||
|
||||
@ -104,7 +104,7 @@ function resolveSidebar(
|
||||
property="itemListElement"
|
||||
typeof="ListItem"
|
||||
>
|
||||
<VPLink :href="link" class="breadcrumb" :class="{ current }" property="item" typeof="WebPage" :text="text" />
|
||||
<VPLink :href="link" class="breadcrumb" :class="{ current }" property="item" typeof="WebPage" :text="text" no-icon />
|
||||
<span v-if="index !== breadcrumbList.length - 1" class="vpi-chevron-right" />
|
||||
<meta property="name" :content="text">
|
||||
<meta property="position" :content="`${index + 1}`">
|
||||
|
||||
@ -39,7 +39,7 @@ const groups = computed(() => matter.value.groups || [])
|
||||
<VPLink
|
||||
class="edit-link-button"
|
||||
:href="editLink.link"
|
||||
:no-icon="true"
|
||||
no-icon
|
||||
>
|
||||
<span class="vpi-square-pen edit-link-icon" aria-label="edit icon" />
|
||||
{{ editLink.text }}
|
||||
|
||||
@ -28,7 +28,8 @@ function linkTo(e: Event) {
|
||||
|
||||
<template>
|
||||
<Component
|
||||
:is="tag" class="vp-link" :class="{ link, 'no-icon': noIcon }"
|
||||
:is="tag"
|
||||
class="vp-link" :class="{ link, 'no-icon': noIcon, 'vp-external-link-icon': isExternal }"
|
||||
:href="link ? isExternalProtocol ? link : isExternal ? link : withBase(link) : undefined"
|
||||
:target="target ?? (isExternal ? '_blank' : undefined)"
|
||||
:rel="rel ?? (isExternal ? 'noreferrer' : undefined)"
|
||||
@ -37,15 +38,5 @@ function linkTo(e: Event) {
|
||||
<slot>
|
||||
{{ text || href }}
|
||||
</slot>
|
||||
<span v-if="isExternal && !noIcon" class="vpi-external-link" />
|
||||
</Component>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
.vp-link .vpi-external-link {
|
||||
width: 11px;
|
||||
height: 11px;
|
||||
margin-top: -1px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -65,6 +65,10 @@ export function useLink(
|
||||
// 判断是否为不存在的路由
|
||||
const routePath = link.split(/[?#]/)[0]
|
||||
const { notFound } = resolveRoute(routePath)
|
||||
|
||||
if (__VUEPRESS_DEV__)
|
||||
notFound && console.warn(`[VuePress Dead Link] "${toValue(href)}" is not found in (${page.value.filePathRelative || page.value.path})`)
|
||||
|
||||
return notFound
|
||||
})
|
||||
|
||||
|
||||
@ -293,7 +293,7 @@
|
||||
* -------------------------------------------------------------------------- */
|
||||
:is(.vp-external-link-icon, .vp-doc a[href*="://"],
|
||||
.vp-doc a[target=_blank])::after {
|
||||
--icon: url("data:image/svg+xml, %3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' %3E%3Cpath d='M0 0h24v24H0V0z' fill='none' /%3E%3Cpath d='M9 5v2h6.59L4 18.59 5.41 20 17 8.41V15h2V5H9z' /%3E%3C/svg%3E");
|
||||
--icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' aria-hidden='true' focusable='false' viewBox='0 0 24 24' %3E %3Cpath d='M0 0h24v24H0V0z' fill='none' /%3E %3Cpath d='M9 5v2h6.59L4 18.59 5.41 20 17 8.41V15h2V5H9z' fill='currentColor' /%3E %3C/svg%3E");
|
||||
|
||||
display: inline-block;
|
||||
flex-shrink: 0;
|
||||
@ -307,12 +307,13 @@
|
||||
mask-image: var(--icon);
|
||||
}
|
||||
|
||||
.vp-external-link-icon::after {
|
||||
.vp-external-link-icon:not(.no-icon)::after {
|
||||
content: "";
|
||||
}
|
||||
|
||||
/* prettier-ignore */
|
||||
.external-link-icon-enabled :is(.vp-doc a[href*="://"], .vp-doc a[target=_blank])::after {
|
||||
.external-link-icon-enabled :is(.vp-doc a[href*='://'],
|
||||
.vp-doc a[target='_blank']):not(:is(.no-icon, svg a, :has(img, svg)))::after {
|
||||
color: currentcolor;
|
||||
content: "";
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user