Skip to content

Commit 8b18598

Browse files
committed
Customize footer to display first published date
1 parent 110d7df commit 8b18598

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@vuepress/bundler-vite": "2.0.0-rc.26",
2626
"@vuepress/plugin-docsearch": "2.0.0-rc.120",
2727
"@vuepress/plugin-links-check": "2.0.0-rc.120",
28+
"dayjs": "^1.11.19",
2829
"element-plus": "^2.12.0",
2930
"sass-embedded": "1.93.3",
3031
"vue": "^3.5.25",

src/.vuepress/components/SidebarLayout.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
</div>
2222
</div>
2323
</template>
24+
<template #contentAfter v-if="firstPublishedDate">
25+
<div style="text-align: right; font-size: 14px; color: #3c3c43; margin-bottom: -45px; margin-top: 32px;">{{ firstPublishedDatePlaceholder }}<span style="color: #3c3c43c7;">{{ firstPublishedDate }}</span></div>
26+
</template>
2427
</Layout>
2528
</template>
2629

@@ -30,12 +33,24 @@ import { Layout } from 'vuepress-theme-hope/client';
3033
import { ref, watch, computed } from 'vue';
3134
import { useRoute, withBase, useRouter } from 'vuepress/client';
3235
import { getDialect, getDocVersion, URL_SUFFIX } from '../utils/index.js';
36+
import { usePageData } from "vuepress/client";
37+
import dayjs from "dayjs";
3338
3439
const route = useRoute();
3540
const router = useRouter();
3641
const currentLang = ref('zh');
3742
const currentVersion = ref('');
3843
const currentDialect = ref('');
44+
const page = usePageData();
45+
46+
const firstPublishedDate = computed(() => {
47+
const raw = page.value.frontmatter.publishedDate;
48+
return raw ? (currentLang.value === 'zh' ? dayjs(raw).format("YYYY/M/D HH:mm") : dayjs(raw).format("D/M/YY, h:mm A")) : null
49+
})
50+
51+
const firstPublishedDatePlaceholder = computed(() => {
52+
return currentLang.value === 'zh' ? '首次发布: ' : 'First Published: ';
53+
})
3954
4055
const ModelName = computed(() => {
4156
return currentLang.value === 'zh' ? {

0 commit comments

Comments
 (0)