fix: 修复note生成sidebar时目录嵌套时未正确识别路径
This commit is contained in:
parent
3bfd7bbf1d
commit
7b3a6e2252
@ -37,6 +37,11 @@ export default defineUserConfig<PlumeThemeOptions>({
|
||||
text: '123',
|
||||
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 const useArchive = (): ArchiveListRef => {
|
||||
const archiveList: ArchiveData = []
|
||||
let archiveList: ArchiveData = []
|
||||
const postList = usePostAllIndex().value
|
||||
postList.forEach((post) => {
|
||||
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)
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ export const usePostAllIndex = (): PostIndexRef => postIndex
|
||||
// 在首页文章列表的,默认排除掉 note中的文章,除非显示声明 article
|
||||
export const usePostIndex = (): PostIndexRef => {
|
||||
const postList = postIndex.value.filter((post) => {
|
||||
return !post.isNote && post.article !== false
|
||||
return !post.isNote || post.article === true
|
||||
})
|
||||
return ref(postList)
|
||||
}
|
||||
|
||||
@ -129,6 +129,21 @@ pre[class*='language-'] {
|
||||
margin: 0.85rem 0;
|
||||
border-radius: 6px;
|
||||
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 {
|
||||
color: #fff;
|
||||
|
||||
@ -50,10 +50,11 @@ export const generateFrontmatter = (
|
||||
) {
|
||||
return currentNote.text
|
||||
}
|
||||
return path
|
||||
.basename(filepath)
|
||||
.replace(/^\d+\./, '')
|
||||
.replace(path.extname(filepath), '')
|
||||
const basename = path.basename(filepath)
|
||||
if (isReadme(basename)) {
|
||||
return path.dirname(filepath).split('/').slice(-1)[0]
|
||||
}
|
||||
return basename.replace(/^\d+\./, '').replace(path.extname(filepath), '')
|
||||
},
|
||||
createTime: ({ createTime }: MarkdownFile, formatTime: string): string => {
|
||||
if (formatTime) return formatTime
|
||||
|
||||
@ -7,12 +7,5 @@ export const resolveComment = (
|
||||
plugins: PlumeThemePluginOptions
|
||||
): PluginConfig => {
|
||||
if (plugins.comment === false) return ['', false]
|
||||
const option: Partial<CommentOptions> = {
|
||||
type: 'giscus',
|
||||
comment: true,
|
||||
}
|
||||
return comment({
|
||||
...(option as CommentOptions),
|
||||
...(plugins.comment as CommentOptions),
|
||||
})
|
||||
return comment(plugins.comment as CommentOptions)
|
||||
}
|
||||
|
||||
@ -114,12 +114,14 @@ function sidebarByConfig(
|
||||
children: [],
|
||||
} as SidebarItem
|
||||
} else {
|
||||
dir = path.join(dir, sidebar.dir || '')
|
||||
link = path.join(link, sidebar.link)
|
||||
const current = sidebar.link
|
||||
? findNotePage(sidebar.link, dir, notePageList)
|
||||
: undefined
|
||||
return {
|
||||
text: sidebar.text,
|
||||
link: current?.link || sidebar.link,
|
||||
text: sidebar.text || sidebar.dir || '',
|
||||
link: current?.link || link,
|
||||
children: sidebarByConfig(
|
||||
sidebar.text,
|
||||
sidebar.link,
|
||||
|
||||
@ -39,5 +39,6 @@ export type PlumeThemeSidebarConfigOptions = (
|
||||
export interface PlumeThemeNotesConfigItem {
|
||||
text: string
|
||||
link?: string
|
||||
children: PlumeThemeNotesConfigItem[]
|
||||
dir?: string
|
||||
children: PlumeThemeSidebarConfigOptions
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user