fix: 修复note生成sidebar时目录嵌套时未正确识别路径
This commit is contained in:
parent
3bfd7bbf1d
commit
7b3a6e2252
@ -37,6 +37,11 @@ export default defineUserConfig<PlumeThemeOptions>({
|
|||||||
text: '123',
|
text: '123',
|
||||||
children: ['1', '2'],
|
children: ['1', '2'],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
text: 'css',
|
||||||
|
dir: 'css',
|
||||||
|
children: ['1', '2'],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
6
docs/notes/typescript/css/1.md
Normal file
6
docs/notes/typescript/css/1.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
title: md
|
||||||
|
createTime: 2022/04/12 12:09:10
|
||||||
|
author: pengzhanbo
|
||||||
|
permalink: /note/typescript/g86ae1b3/
|
||||||
|
---
|
||||||
6
docs/notes/typescript/css/2.md
Normal file
6
docs/notes/typescript/css/2.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
title: md
|
||||||
|
createTime: 2022/04/12 12:09:15
|
||||||
|
author: pengzhanbo
|
||||||
|
permalink: /note/typescript/vruetr0c/
|
||||||
|
---
|
||||||
@ -18,7 +18,7 @@ export type ArchiveData = ArchiveItem[]
|
|||||||
export type ArchiveListRef = Ref<ArchiveData>
|
export type ArchiveListRef = Ref<ArchiveData>
|
||||||
|
|
||||||
export const useArchive = (): ArchiveListRef => {
|
export const useArchive = (): ArchiveListRef => {
|
||||||
const archiveList: ArchiveData = []
|
let archiveList: ArchiveData = []
|
||||||
const postList = usePostAllIndex().value
|
const postList = usePostAllIndex().value
|
||||||
postList.forEach((post) => {
|
postList.forEach((post) => {
|
||||||
const [year, month, day] = post.createTime.split('-')
|
const [year, month, day] = post.createTime.split('-')
|
||||||
@ -34,5 +34,9 @@ export const useArchive = (): ArchiveListRef => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
archiveList = archiveList.sort((left, right) => {
|
||||||
|
return left.year > right.year ? 1 : -1
|
||||||
|
})
|
||||||
|
|
||||||
return ref(archiveList)
|
return ref(archiveList)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ export const usePostAllIndex = (): PostIndexRef => postIndex
|
|||||||
// 在首页文章列表的,默认排除掉 note中的文章,除非显示声明 article
|
// 在首页文章列表的,默认排除掉 note中的文章,除非显示声明 article
|
||||||
export const usePostIndex = (): PostIndexRef => {
|
export const usePostIndex = (): PostIndexRef => {
|
||||||
const postList = postIndex.value.filter((post) => {
|
const postList = postIndex.value.filter((post) => {
|
||||||
return !post.isNote && post.article !== false
|
return !post.isNote || post.article === true
|
||||||
})
|
})
|
||||||
return ref(postList)
|
return ref(postList)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -129,6 +129,21 @@ pre[class*='language-'] {
|
|||||||
margin: 0.85rem 0;
|
margin: 0.85rem 0;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
scrollbar-width: thin;
|
||||||
|
scrollbar-color: var(--c-brand) var(--c-border);
|
||||||
|
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-webkit-scrollbar-track {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-webkit-scrollbar-thumb {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
code {
|
code {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
|||||||
@ -50,10 +50,11 @@ export const generateFrontmatter = (
|
|||||||
) {
|
) {
|
||||||
return currentNote.text
|
return currentNote.text
|
||||||
}
|
}
|
||||||
return path
|
const basename = path.basename(filepath)
|
||||||
.basename(filepath)
|
if (isReadme(basename)) {
|
||||||
.replace(/^\d+\./, '')
|
return path.dirname(filepath).split('/').slice(-1)[0]
|
||||||
.replace(path.extname(filepath), '')
|
}
|
||||||
|
return basename.replace(/^\d+\./, '').replace(path.extname(filepath), '')
|
||||||
},
|
},
|
||||||
createTime: ({ createTime }: MarkdownFile, formatTime: string): string => {
|
createTime: ({ createTime }: MarkdownFile, formatTime: string): string => {
|
||||||
if (formatTime) return formatTime
|
if (formatTime) return formatTime
|
||||||
|
|||||||
@ -7,12 +7,5 @@ export const resolveComment = (
|
|||||||
plugins: PlumeThemePluginOptions
|
plugins: PlumeThemePluginOptions
|
||||||
): PluginConfig => {
|
): PluginConfig => {
|
||||||
if (plugins.comment === false) return ['', false]
|
if (plugins.comment === false) return ['', false]
|
||||||
const option: Partial<CommentOptions> = {
|
return comment(plugins.comment as CommentOptions)
|
||||||
type: 'giscus',
|
|
||||||
comment: true,
|
|
||||||
}
|
|
||||||
return comment({
|
|
||||||
...(option as CommentOptions),
|
|
||||||
...(plugins.comment as CommentOptions),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -114,12 +114,14 @@ function sidebarByConfig(
|
|||||||
children: [],
|
children: [],
|
||||||
} as SidebarItem
|
} as SidebarItem
|
||||||
} else {
|
} else {
|
||||||
|
dir = path.join(dir, sidebar.dir || '')
|
||||||
|
link = path.join(link, sidebar.link)
|
||||||
const current = sidebar.link
|
const current = sidebar.link
|
||||||
? findNotePage(sidebar.link, dir, notePageList)
|
? findNotePage(sidebar.link, dir, notePageList)
|
||||||
: undefined
|
: undefined
|
||||||
return {
|
return {
|
||||||
text: sidebar.text,
|
text: sidebar.text || sidebar.dir || '',
|
||||||
link: current?.link || sidebar.link,
|
link: current?.link || link,
|
||||||
children: sidebarByConfig(
|
children: sidebarByConfig(
|
||||||
sidebar.text,
|
sidebar.text,
|
||||||
sidebar.link,
|
sidebar.link,
|
||||||
|
|||||||
@ -39,5 +39,6 @@ export type PlumeThemeSidebarConfigOptions = (
|
|||||||
export interface PlumeThemeNotesConfigItem {
|
export interface PlumeThemeNotesConfigItem {
|
||||||
text: string
|
text: string
|
||||||
link?: string
|
link?: string
|
||||||
children: PlumeThemeNotesConfigItem[]
|
dir?: string
|
||||||
|
children: PlumeThemeSidebarConfigOptions
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user