Skip to content

Commit

Permalink
feat: add externalLink frontmatter
Browse files Browse the repository at this point in the history
  • Loading branch information
pengzhanbo committed Jan 31, 2024
1 parent 28cfb04 commit eb30e03
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion theme/src/client/components/global/ExternalLinkIcon.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<script lang="ts" setup>
import { usePageFrontmatter } from 'vuepress/client'
import { computed } from 'vue'
import IconExternalLink from '../icons/IconExternalLink.vue'
import type { PlumeThemePageFrontmatter } from '../../../shared/index.js'
const matter = usePageFrontmatter<PlumeThemePageFrontmatter>()
const show = computed(() => matter.value.externalLink !== false)
</script>

<template>
<IconExternalLink class="external-icon" />
<IconExternalLink v-if="show" class="external-icon" />
</template>

<style scoped>
Expand All @@ -16,4 +22,10 @@ import IconExternalLink from '../icons/IconExternalLink.vue'
color: var(--vp-c-text-3);
vertical-align: middle;
}
@media print {
.external-icon {
display: none;
}
}
</style>
1 change: 1 addition & 0 deletions theme/src/shared/frontmatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface PlumeThemePageFrontmatter {
prev?: string | NavItemWithLink
next?: string | NavItemWithLink
backToTop?: boolean
externalLink?: boolean
}

export interface PlumeThemePostFrontmatter extends PlumeThemePageFrontmatter {
Expand Down

0 comments on commit eb30e03

Please sign in to comment.