diff --git a/plugins/plugin-notes-data/src/node/plugin.ts b/plugins/plugin-notes-data/src/node/plugin.ts index e1e737f5..077e0b3e 100644 --- a/plugins/plugin-notes-data/src/node/plugin.ts +++ b/plugins/plugin-notes-data/src/node/plugin.ts @@ -4,15 +4,15 @@ import type { NotesDataOptions } from '../shared/index.js' import { prepareNotesData, watchNotesData } from './prepareNotesData.js' export function notesDataPlugin(options: NotesDataOptions | NotesDataOptions[]): Plugin { - return (app: App) => { - return { - name: '@vuepress-plume/plugin-notes-data', - clientConfigFile: path.join( - getDirname(import.meta.url), - '../client/clientConfig.js', - ), - onPrepared: () => prepareNotesData(app, options), - onWatched: (app, watchers) => watchNotesData(app, watchers, options), - } + return { + name: '@vuepress-plume/plugin-notes-data', + + clientConfigFile: path.join( + getDirname(import.meta.url), + '../client/clientConfig.js', + ), + + onPrepared: app => prepareNotesData(app, options), + onWatched: (app, watchers) => watchNotesData(app, watchers, options), } } diff --git a/theme/src/client/composables/sidebar.ts b/theme/src/client/composables/sidebar.ts index 40f4cac0..647447af 100644 --- a/theme/src/client/composables/sidebar.ts +++ b/theme/src/client/composables/sidebar.ts @@ -11,6 +11,7 @@ import { computed, onMounted, onUnmounted, ref, watch, watchEffect } from 'vue' import type { PlumeThemePageData } from '../../shared/index.js' import { isActive } from '../utils/index.js' import { hashRef } from './hash.js' +import { useData } from './data.js' export { useNotesData } @@ -57,8 +58,7 @@ export function getSidebarFirstLink(sidebar: NotesSidebarItem[]) { export function useSidebar() { const route = useRoute() const notesData = useNotesData() - const frontmatter = usePageFrontmatter() - const page = usePageData() + const { frontmatter } = useData() const is960 = useMediaQuery('(min-width: 960px)') @@ -72,12 +72,15 @@ export function useSidebar() { }) const sidebar = computed(() => { - return getSidebarList(route.path, notesData.value) + const link = typeof frontmatter.value.sidebar === 'string' + ? frontmatter.value.sidebar + : route.path + return getSidebarList(link, notesData.value) }) + const hasSidebar = computed(() => { return ( !frontmatter.value.home - && !page.value.isBlogPost && sidebar.value.length > 0 && frontmatter.value.sidebar !== false ) diff --git a/theme/src/node/config/resolveThemeData.ts b/theme/src/node/config/resolveThemeData.ts index 69a87186..425b7558 100644 --- a/theme/src/node/config/resolveThemeData.ts +++ b/theme/src/node/config/resolveThemeData.ts @@ -30,7 +30,7 @@ export function resolveThemeData(app: App, options: PlumeThemeLocaleOptions): Pl entries(options.locales || {}).forEach(([locale, opt]) => { // 注入预设 导航栏 // home | blog | tags | archives - if (opt.navbar !== false && opt.navbar?.length === 0) { + if (opt.navbar !== false && (!opt.navbar || opt.navbar.length === 0)) { // fallback navbar option const localePath = locale === '/' ? root : locale const navbar: NavItem[] = [{ diff --git a/theme/src/shared/frontmatter.ts b/theme/src/shared/frontmatter.ts index 22e40098..e7b7e53e 100644 --- a/theme/src/shared/frontmatter.ts +++ b/theme/src/shared/frontmatter.ts @@ -113,6 +113,7 @@ export interface PlumeThemeHomeCustom extends PlumeHomeConfigBase { /* =============================== Home end ==================================== */ export interface PlumeThemePageFrontmatter { + home?: false comments?: boolean editLink?: boolean editLinkPattern?: string @@ -120,6 +121,8 @@ export interface PlumeThemePageFrontmatter { contributors?: boolean prev?: string | NavItemWithLink next?: string | NavItemWithLink + sidebar?: string | false + aside?: boolean outline?: ThemeOutline backToTop?: boolean externalLink?: boolean