Merge pull request #51 from huankong233/main

优化功能
This commit is contained in:
pengzhanbo 2024-02-11 02:17:57 +08:00 committed by GitHub
commit b4057e3820
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 10 deletions

View File

@ -114,11 +114,29 @@ function initSidebarByAuto(
note: NotesItemOptions,
pages: NotePage[],
): NotesSidebarItem[] {
pages = pages.sort((prev, next) => {
const pi = prev.relativePath.match(/\//g)?.length || 0
const ni = next.relativePath.match(/\//g)?.length || 0
return pi < ni ? -1 : 1
let tempPages = pages.map(page => {
return { ...page, splitPath: page.relativePath.split('/') }
})
const maxIndex = Math.max(...tempPages.map(page => page.splitPath.length))
let nowIndex = 0
while (nowIndex < maxIndex) {
tempPages = tempPages.sort((prev, next) => {
const pi = prev.splitPath?.[nowIndex]?.match(/(\d+)\.(?=[^/]+$)/)?.[1]
const ni = next.splitPath?.[nowIndex]?.match(/(\d+)\.(?=[^/]+$)/)?.[1]
if (!pi || !ni) return 0
return parseFloat(pi) < parseFloat(ni) ? -1 : 1
})
nowIndex++
}
pages = tempPages.map(page => {
delete page.splitPath;
return page
})
const RE_INDEX = ['index.md', 'README.md', 'readme.md']
const result: NotesSidebarItem[] = []
for (const page of pages) {

View File

@ -139,12 +139,6 @@ const createTime = computed(() =>
}
}
@media (min-width: 1200px) {
.post-item {
margin-left: 0;
}
}
.post-meta {
display: flex;
flex-wrap: wrap;