chore: tweak
This commit is contained in:
parent
ec7f9b00b3
commit
b115a3ea73
@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<PlumeThemePageData>()
|
||||
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
|
||||
)
|
||||
|
||||
@ -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[] = [{
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user