diff --git a/package.json b/package.json index 9a97c78c6..1f41525fb 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "@vuepress/bundler-vite": "2.0.0-rc.26", "@vuepress/plugin-docsearch": "2.0.0-rc.120", "@vuepress/plugin-links-check": "2.0.0-rc.120", + "dayjs": "^1.11.19", "element-plus": "^2.12.0", "sass-embedded": "1.93.3", "vue": "^3.5.25", diff --git a/src/.vuepress/components/SidebarLayout.vue b/src/.vuepress/components/SidebarLayout.vue index 1126a0792..293deb304 100644 --- a/src/.vuepress/components/SidebarLayout.vue +++ b/src/.vuepress/components/SidebarLayout.vue @@ -21,6 +21,9 @@ + @@ -30,12 +33,24 @@ import { Layout } from 'vuepress-theme-hope/client'; import { ref, watch, computed } from 'vue'; import { useRoute, withBase, useRouter } from 'vuepress/client'; import { getDialect, getDocVersion, URL_SUFFIX } from '../utils/index.js'; +import { usePageData } from "vuepress/client"; +import dayjs from "dayjs"; const route = useRoute(); const router = useRouter(); const currentLang = ref('zh'); const currentVersion = ref(''); const currentDialect = ref(''); +const page = usePageData(); + +const firstPublishedDate = computed(() => { + const raw = page.value.frontmatter.publishedDate; + return raw ? (currentLang.value === 'zh' ? dayjs(raw).format("YYYY/M/D HH:mm") : dayjs(raw).format("D/M/YY, h:mm A")) : null +}) + +const firstPublishedDatePlaceholder = computed(() => { + return currentLang.value === 'zh' ? '首次发布: ' : 'First Published: '; +}) const ModelName = computed(() => { return currentLang.value === 'zh' ? {