diff --git a/docs/.vuepress/config.ts b/docs/.vuepress/config.ts index bf1fa23e..e8ec592a 100644 --- a/docs/.vuepress/config.ts +++ b/docs/.vuepress/config.ts @@ -37,6 +37,11 @@ export default defineUserConfig({ text: '123', children: ['1', '2'], }, + { + text: 'css', + dir: 'css', + children: ['1', '2'], + }, ], }, ], diff --git a/docs/notes/typescript/css/1.md b/docs/notes/typescript/css/1.md new file mode 100644 index 00000000..93a4597e --- /dev/null +++ b/docs/notes/typescript/css/1.md @@ -0,0 +1,6 @@ +--- +title: md +createTime: 2022/04/12 12:09:10 +author: pengzhanbo +permalink: /note/typescript/g86ae1b3/ +--- diff --git a/docs/notes/typescript/css/2.md b/docs/notes/typescript/css/2.md new file mode 100644 index 00000000..b5752767 --- /dev/null +++ b/docs/notes/typescript/css/2.md @@ -0,0 +1,6 @@ +--- +title: md +createTime: 2022/04/12 12:09:15 +author: pengzhanbo +permalink: /note/typescript/vruetr0c/ +--- diff --git a/packages/theme/src/client/composables/archive.ts b/packages/theme/src/client/composables/archive.ts index d6bae010..a8dbfe47 100644 --- a/packages/theme/src/client/composables/archive.ts +++ b/packages/theme/src/client/composables/archive.ts @@ -18,7 +18,7 @@ export type ArchiveData = ArchiveItem[] export type ArchiveListRef = Ref 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) } diff --git a/packages/theme/src/client/composables/postIndex.ts b/packages/theme/src/client/composables/postIndex.ts index 635bc195..95412568 100644 --- a/packages/theme/src/client/composables/postIndex.ts +++ b/packages/theme/src/client/composables/postIndex.ts @@ -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) } diff --git a/packages/theme/src/client/styles/code.scss b/packages/theme/src/client/styles/code.scss index 1d03fa0c..e66b71ac 100644 --- a/packages/theme/src/client/styles/code.scss +++ b/packages/theme/src/client/styles/code.scss @@ -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; diff --git a/packages/theme/src/node/generateFrontmatter.ts b/packages/theme/src/node/generateFrontmatter.ts index c24e6de6..71e72fde 100644 --- a/packages/theme/src/node/generateFrontmatter.ts +++ b/packages/theme/src/node/generateFrontmatter.ts @@ -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 diff --git a/packages/theme/src/node/plugins/comment.ts b/packages/theme/src/node/plugins/comment.ts index efc12dec..4020f2fc 100644 --- a/packages/theme/src/node/plugins/comment.ts +++ b/packages/theme/src/node/plugins/comment.ts @@ -7,12 +7,5 @@ export const resolveComment = ( plugins: PlumeThemePluginOptions ): PluginConfig => { if (plugins.comment === false) return ['', false] - const option: Partial = { - type: 'giscus', - comment: true, - } - return comment({ - ...(option as CommentOptions), - ...(plugins.comment as CommentOptions), - }) + return comment(plugins.comment as CommentOptions) } diff --git a/packages/theme/src/node/prepared/sidebarIndex.ts b/packages/theme/src/node/prepared/sidebarIndex.ts index f2389a01..a0855ef8 100644 --- a/packages/theme/src/node/prepared/sidebarIndex.ts +++ b/packages/theme/src/node/prepared/sidebarIndex.ts @@ -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, diff --git a/packages/theme/src/shared/options/notes.ts b/packages/theme/src/shared/options/notes.ts index 8c989aca..602034a9 100644 --- a/packages/theme/src/shared/options/notes.ts +++ b/packages/theme/src/shared/options/notes.ts @@ -39,5 +39,6 @@ export type PlumeThemeSidebarConfigOptions = ( export interface PlumeThemeNotesConfigItem { text: string link?: string - children: PlumeThemeNotesConfigItem[] + dir?: string + children: PlumeThemeSidebarConfigOptions }