feat(theme): 新增导航栏社交图标过滤器
This commit is contained in:
parent
308c31408a
commit
c09cd98075
@ -13,6 +13,16 @@ const { localeLinks, currentLang } = useLangs({ correspondingLink: true })
|
||||
const hasExtraContent = computed(
|
||||
() => theme.value.appearance || theme.value.social,
|
||||
)
|
||||
|
||||
const social = computed(() => {
|
||||
const includes = theme.value.navbarSocialInclude ?? []
|
||||
if (!includes.length)
|
||||
return theme.value.social
|
||||
|
||||
return theme.value.social?.filter(
|
||||
({ icon }) => typeof icon === 'string' && includes.includes(icon),
|
||||
)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@ -41,9 +51,9 @@ const hasExtraContent = computed(
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="theme.social" class="group">
|
||||
<div v-if="social" class="group">
|
||||
<div class="item social-links">
|
||||
<SocialLinks class="social-links-list" :links="theme.social" />
|
||||
<SocialLinks class="social-links-list" :links="social" />
|
||||
</div>
|
||||
</div>
|
||||
</Flyout>
|
||||
|
||||
@ -1,15 +1,26 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue'
|
||||
import { useThemeLocaleData } from '../../composables/index.js'
|
||||
import SocialLinks from '../SocialLinks.vue'
|
||||
|
||||
const theme = useThemeLocaleData()
|
||||
|
||||
const social = computed(() => {
|
||||
const includes = theme.value.navbarSocialInclude ?? []
|
||||
if (!includes.length)
|
||||
return theme.value.social
|
||||
|
||||
return theme.value.social?.filter(
|
||||
({ icon }) => typeof icon === 'string' && includes.includes(icon),
|
||||
)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SocialLinks
|
||||
v-if="theme.social"
|
||||
v-if="social"
|
||||
class="navbar-social-links"
|
||||
:links="theme.social"
|
||||
:links="social"
|
||||
/>
|
||||
</template>
|
||||
|
||||
|
||||
@ -51,6 +51,7 @@ export const fallbackLocaleOption: Partial<PlumeThemeLocaleOptions> = {
|
||||
article: '/article/',
|
||||
notes: { link: '/', dir: 'notes', notes: [] },
|
||||
appearance: true,
|
||||
navbarSocialInclude: ['github', 'twitter', 'discord', 'facebook'],
|
||||
// page meta
|
||||
editLink: true,
|
||||
lastUpdated: true,
|
||||
|
||||
@ -19,6 +19,16 @@ export interface PlumeThemeAvatar {
|
||||
* 是否显示为圆形头像
|
||||
*/
|
||||
circle?: boolean
|
||||
|
||||
/**
|
||||
* 地理位置
|
||||
*/
|
||||
location?: string
|
||||
|
||||
/**
|
||||
* 组织,公司
|
||||
*/
|
||||
organization?: string
|
||||
}
|
||||
|
||||
export interface SocialLink {
|
||||
@ -26,7 +36,7 @@ export interface SocialLink {
|
||||
link: string
|
||||
}
|
||||
|
||||
export type SocialLinkIcon =
|
||||
export type SocialLinkIconUnion =
|
||||
| 'discord'
|
||||
| 'facebook'
|
||||
| 'github'
|
||||
@ -41,7 +51,16 @@ export type SocialLinkIcon =
|
||||
| 'qq'
|
||||
| 'weibo'
|
||||
| 'bilibili'
|
||||
| { svg: string }
|
||||
| 'gitlab'
|
||||
| 'docker'
|
||||
| 'juejin'
|
||||
| 'zhihu'
|
||||
| 'douban'
|
||||
| 'steam'
|
||||
| 'stackoverflow'
|
||||
| 'xbox'
|
||||
|
||||
export type SocialLinkIcon = SocialLinkIconUnion | { svg: string }
|
||||
|
||||
export interface PlumeThemeBlog {
|
||||
|
||||
@ -174,6 +193,12 @@ export interface PlumeThemeLocaleData extends LocaleData {
|
||||
*/
|
||||
social?: SocialLink[]
|
||||
|
||||
/**
|
||||
* 允许显示在导航栏的社交类型
|
||||
* @default - ['github', 'twitter', 'discord', 'facebook']
|
||||
*/
|
||||
navbarSocialInclude?: SocialLinkIconUnion[]
|
||||
|
||||
/**
|
||||
* 博客配置
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user