Skip to content

Navigation Menu

Sign in
Sign up

Customize layout to display first published date #1014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
LJW21-02 wants to merge 1 commit into apache:main
base: main
Choose a base branch
Loading
from LJW21-02:footer-publish-date
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 15 additions & 0 deletions src/.vuepress/components/SidebarLayout.vue
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
</div>
</div>
</template>
<template #contentAfter v-if="firstPublishedDate">
<div style="text-align: right; font-size: 14px; color: #3c3c43; margin-bottom: -45px; margin-top: 32px;">{{ firstPublishedDatePlaceholder }}<span style="color: #3c3c43c7;">{{ firstPublishedDate }}</span></div>
</template>
</Layout>
</template>

Expand All @@ -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' ? {
Expand Down
Loading

AltStyle によって変換されたページ (->オリジナル) /