feat(theme): add support layout for blog profile (#182)

This commit is contained in:
pengzhanbo 2024-09-16 02:32:15 +08:00 committed by GitHub
parent 5f0dd0dfa2
commit db28c8bd8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 28 additions and 5 deletions

View File

@ -247,6 +247,7 @@ interface BlogOptions {
- `profile.circle`: 是否为圆形头像
- `profile.location`: 用户地理位置
- `profile.organization`: 用户所在组织/公司
- `profile.layout`: 个人信息展示在左侧还是右侧,`'left' | 'right'`
示例:
@ -260,6 +261,7 @@ export default {
circle: true,
location: '杭州,中国',
organization: 'xxx公司',
layout: 'right',
}
})
}

View File

@ -52,11 +52,19 @@ import VPBlogProfile from 'vuepress-theme-plume/components/Blog/VPBlogProfile.vu
export default defineUserConfig({
theme: plumeTheme({
profile: {
name: '的名字',
description: '描述文字',
name: '的名字',
description: '描述文字,座右铭/签名',
avatar: '/blogger.png',
location: '您的位置',
organization: '您的组织',
circle: true, // 是否为圆形头像
}
layout: 'right', // 个人信息在左侧还是右侧,'left' | 'right'
},
// 社交链接
social: [
{ icon: 'github', link: 'https://github.com/vuepress-theme-plume' },
// ... more
]
})
})
```

View File

@ -22,7 +22,10 @@ const { theme, page } = useData()
<div class="vp-blog" :class="{ 'home-blog': homeBlog }" vp-blog>
<slot name="blog-top" />
<div class="blog-container" :class="{ 'no-profile': !theme.profile }">
<div
class="blog-container"
:class="{ 'no-profile': !theme.profile, 'left': theme.profile?.layout === 'left' }"
>
<VPBlogNav v-if="!theme.profile" is-local />
<VPTransitionFadeSlideY>
@ -117,6 +120,10 @@ const { theme, page } = useData()
margin: 0 auto;
}
.blog-container:not(.no-profile).left {
flex-direction: row-reverse;
}
.blog-container.no-profile {
display: block;
max-width: 784px;

View File

@ -17,7 +17,7 @@ const svg = computed(() => {
<template>
<a
class="vp-social-link"
class="vp-social-link no-icon"
:href="link"
:aria-label="ariaLabel ?? (typeof icon === 'string' ? icon : '')"
target="_blank" rel="noopener" v-html="svg"

View File

@ -326,6 +326,12 @@ export interface PlumeThemeProfile {
*
*/
organization?: string
/**
*
* @default 'right'
*/
layout?: 'left' | 'right'
}
/** ========================== Page Meta ====================== */