Skip to content

Commit ef27403

Browse files
committed
update layout and config
1 parent 001de35 commit ef27403

File tree

6 files changed

+58
-12
lines changed

6 files changed

+58
-12
lines changed

docs/.vuepress/theme/lib/client/components/Page.vue

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts" setup>
22
import Sidebar from "./Sidebar.vue"
3+
import ReadingTime from "./ReadingTime.vue"
34
import PageMeta from "./PageMeta.vue"
45
import PageNav from "./PageNav.vue"
56
import SubToc from "./SubToc.vue"
@@ -15,10 +16,10 @@ import { defaultConstants } from "../../shared"
1516
import type {
1617
DefaultThemePageFrontmatter,
1718
DefaultThemeLocaleData,
18-
DefaultThemePageData,
19+
ThemePageData,
1920
} from "../../shared"
2021
21-
const pageData = usePageData<DefaultThemePageData>()
22+
const pageData = usePageData<ThemePageData>()
2223
const pageFrontmatter = usePageFrontmatter<DefaultThemePageFrontmatter>()
2324
const themeData = useThemeData<DefaultThemeLocaleData>()
2425
@@ -32,6 +33,14 @@ const isSidebarCategroyActive = computed(() =>
3233
usePluginState("sidebarCategory", computedStateSource.value)
3334
)
3435
36+
const isReadingTimeActive = computed(() =>
37+
usePluginState("readingTime", computedStateSource.value)
38+
)
39+
40+
const isPageMetaActive = computed(() =>
41+
usePluginState("pageMeta", computedStateSource.value)
42+
)
43+
3544
const isSidebarActive = computed(() =>
3645
usePluginState("sidebar", computedStateSource.value)
3746
)
@@ -71,9 +80,8 @@ setupHeaders()
7180
<slot name="page-title">{{ pageTitle }}</slot>
7281
</h1>
7382

74-
<PageMeta
75-
v-if="pageData.git.createdTime && pageData.git.contributors.length"
76-
/>
83+
<PageMeta v-if="isPageMetaActive" />
84+
<ReadingTime :data="pageData.readingTime" v-if="isReadingTimeActive" />
7785
<slot name="after-page-head"></slot>
7886
</div>
7987

docs/.vuepress/theme/lib/client/components/PageMeta.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ const contributors = useContributors()
2626
<span class="meta-item-label">{{ themeLocale.contributorsText }}</span>
2727
<span class="meta-item-info">
2828
<template v-for="(contributor, index) in contributors" :key="index">
29-
<span class="contributor" :title="`email: ${contributor.email}`">
29+
<a
30+
class="contributor"
31+
:title="`email: ${contributor.email}`"
32+
:href="`mailto://${contributor.email}`"
33+
>
3034
{{ contributor.name }}
31-
</span>
35+
</a>
3236
<template v-if="index !== contributors.length - 1">, </template>
3337
</template>
3438
</span>
@@ -53,10 +57,7 @@ const contributors = useContributors()
5357
}
5458
5559
.meta-item-label {
56-
@apply pr-1.5
57-
font-bold
58-
border-r border-slate-300 dark:border-slate-600
59-
transition-colors ease-in-out duration-300;
60+
@apply pr-1.5 font-bold;
6061
}
6162
.meta-item-info {
6263
@apply font-mono;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<script lang="ts" setup>
2+
import { toRefs } from "vue"
3+
import type { ReadingTime } from "@vuepress/plugin-reading-time/client"
4+
5+
const $props = defineProps<{
6+
data?: ReadingTime
7+
}>()
8+
const { data } = toRefs($props)
9+
</script>
10+
11+
<template>
12+
<div class="page-reading-time" v-if="data">
13+
<span class="reading-time-label">📖阅读时间</span>
14+
<span class="reading-time">
15+
总字数 {{ data.words }}, 大约需要 {{ data.minutes }} 分钟阅读
16+
</span>
17+
</div>
18+
</template>
19+
20+
<style lang="postcss" scoped>
21+
.page-reading-time {
22+
@apply w-full inline-flex items-center gap-x-2
23+
text-sm text-gray-500 dark:text-gray-400
24+
transition-colors ease-in-out duration-300;
25+
}
26+
27+
.reading-time-label {
28+
@apply font-bold;
29+
}
30+
.reading-time {
31+
@apply text-sm;
32+
}
33+
</style>

docs/.vuepress/theme/lib/client/layouts/Base.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ div[data-highlighter="shiki"] {
175175
/* transitions */
176176
.fade-enter-active,
177177
.fade-leave-active {
178-
@apply transition-opacity ease-in-out duration-100;
178+
@apply transition-all ease-in-out duration-100;
179179
}
180180
.fade-enter-from,
181181
.fade-leave-to {

docs/.vuepress/theme/lib/node/utils/useBlog.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export const useBlogPlugin = () =>
4747
readingTime: false,
4848
readingLine: false,
4949
comment: false,
50+
pageMeta: false,
5051
sidebarCategory: false,
5152
sidebar: false,
5253
},
@@ -60,6 +61,7 @@ export const useBlogPlugin = () =>
6061
plugins: {
6162
readingTime: false,
6263
readingLine: false,
64+
pageMeta: false,
6365
comment: false,
6466
sidebarCategory: false,
6567
sidebar: false,
@@ -91,6 +93,7 @@ export const useBlogPlugin = () =>
9193
plugins: {
9294
readingTime: false,
9395
readingLine: false,
96+
pageMeta: false,
9497
comment: false,
9598
sidebarCategory: false,
9699
sidebar: false,

docs/.vuepress/theme/lib/shared/component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface PaginationProps {
3232
export type PluginName =
3333
| "readingTime"
3434
| "readingLine"
35+
| "pageMeta"
3536
| "comment"
3637
| "sidebar"
3738
| "sidebarCategory"

0 commit comments

Comments
 (0)