feat: 移除 externalLink插件,在主题内实现

This commit is contained in:
pengzhanbo 2024-05-22 16:37:08 +08:00
parent 5af709a762
commit 3d7199fe29
5 changed files with 53 additions and 12 deletions

View File

@ -31,6 +31,7 @@
"editor.formatOnSave": false,
"prettier.enable": false,
"editor.codeActionsOnSave": {
"source.fixAll.stylelint": "explicit",
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},

View File

@ -1,18 +1,29 @@
<script lang="ts" setup>
import { computed } from 'vue'
import { usePageFrontmatter } from 'vuepress/client'
import { useSidebar } from '../composables/index.js'
import { useThemeLocaleData } from '../composables/themeData.js'
import type { PlumeThemePageFrontmatter } from '../../shared/index.js'
const props = defineProps<{
isNotFound?: boolean
}>()
const { hasSidebar } = useSidebar()
const theme = useThemeLocaleData()
const frontmatter = usePageFrontmatter<PlumeThemePageFrontmatter>()
const enabledExternalIcon = computed(() => {
return frontmatter.value.externalLink ?? theme.value.externalLinkIcon ?? true
})
</script>
<template>
<div
id="LayoutContent"
class="layout-content"
:class="{ 'has-sidebar': hasSidebar && !props.isNotFound }"
id="LayoutContent" class="layout-content" :class="{
'has-sidebar': hasSidebar && !props.isNotFound,
'external-link-icon-enabled': enabledExternalIcon,
}"
>
<slot />
</div>

View File

@ -268,3 +268,31 @@
.plume-content a:hover > code {
color: var(--vp-code-link-hover-color);
}
/**
* External links
* -------------------------------------------------------------------------- */
:is(.vp-external-link-icon, .plume-content a[href*='://'], .plume-content a[target='_blank']):not(.no-icon)::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");
display: inline-block;
flex-shrink: 0;
width: 11px;
height: 11px;
margin-top: -1px;
margin-left: 4px;
color: var(--vp-c-text-3);
background: currentcolor;
-webkit-mask-image: var(--icon);
mask-image: var(--icon);
}
.vp-external-link-icon::after {
content: "";
}
/* prettier-ignore */
.external-link-icon-enabled :is(.plume-content a[href*='://'], .plume-content a[target='_blank'])::after {
color: currentcolor;
content: "";
}

View File

@ -336,10 +336,6 @@ export interface PlumeThemeLocaleData extends LocaleData {
* The text to replace the default "Contributors"
*/
contributorsText?: string
/**
*
*/
openInNewWindow?: string | boolean
// backToHome?: string
@ -353,12 +349,22 @@ export interface PlumeThemeLocaleData extends LocaleData {
*/
returnToTopLabel?: string
/**
* outline
*
* @default 'On this page'
*/
outlineLabel?: string
prevPageLabel?: string
nextPageLabel?: string
/**
*
*/
externalLinkIcon?: string
footer?:
| false
| {

View File

@ -18,11 +18,6 @@ export interface PlumeThemePluginOptions {
*/
caniuse?: false
/**
* external-link-icon
*/
externalLinkIcon?: false
/**
* plugin-search
*/