fix: normalize path posix
This commit is contained in:
parent
ae2fb0b601
commit
78cea01c88
@ -59,7 +59,7 @@ export const prepareNotesData = async (
|
||||
|
||||
const notesData: NotesData = {}
|
||||
notes.forEach((note) => {
|
||||
notesData[path.join('/', link, note.link)] = initSidebar(
|
||||
notesData[normalizePath(path.join('/', link, note.link))] = initSidebar(
|
||||
note,
|
||||
notesPageList.filter((page) =>
|
||||
page.relativePath.startsWith(note.dir.trim().replace(/^\/|\/$/g, ''))
|
||||
@ -160,7 +160,7 @@ function initSidebarByConfig(
|
||||
link: item.link || '',
|
||||
text: item.text || '',
|
||||
sidebar: item.items,
|
||||
dir: path.join(dir, item.dir || ''),
|
||||
dir: normalizePath(path.join(dir, item.dir || '')),
|
||||
},
|
||||
pages
|
||||
),
|
||||
@ -178,16 +178,16 @@ function findNotePage(
|
||||
return notePageList.find((page) => {
|
||||
const relative = page.relativePath
|
||||
return (
|
||||
relative === path.join(dir, 'README.md') ||
|
||||
relative === path.join(dir, 'index.md')
|
||||
relative === normalizePath(path.join(dir, 'README.md')) ||
|
||||
relative === normalizePath(path.join(dir, 'index.md'))
|
||||
)
|
||||
})
|
||||
} else {
|
||||
return notePageList.find((page) => {
|
||||
const relative = page.relativePath
|
||||
return (
|
||||
relative === path.join(dir, sidebar) ||
|
||||
relative === path.join(dir, sidebar + '.md') ||
|
||||
relative === normalizePath(path.join(dir, sidebar)) ||
|
||||
relative === normalizePath(path.join(dir, sidebar + '.md')) ||
|
||||
page.link === sidebar
|
||||
)
|
||||
})
|
||||
|
||||
@ -22,6 +22,10 @@ const getPackage = () => {
|
||||
return pkg
|
||||
}
|
||||
|
||||
const normalizePath = (dir: string) => {
|
||||
return dir.replace(/\\+/g, '/')
|
||||
}
|
||||
|
||||
export default function autoFrontmatter(
|
||||
app: App,
|
||||
localeOption: PlumeThemeLocaleOptions
|
||||
@ -127,12 +131,14 @@ export default function autoFrontmatter(
|
||||
const locale = resolveLocale(filepath)
|
||||
const note = findNote(filepath)
|
||||
const notes = notesByLocale(locale)
|
||||
return path.join(
|
||||
locale,
|
||||
notes?.link || '',
|
||||
note?.link || getCurrentDirname(note, filepath),
|
||||
nanoid(),
|
||||
'/'
|
||||
return normalizePath(
|
||||
path.join(
|
||||
locale,
|
||||
notes?.link || '',
|
||||
note?.link || getCurrentDirname(note, filepath),
|
||||
nanoid(),
|
||||
'/'
|
||||
)
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -154,7 +160,9 @@ export default function autoFrontmatter(
|
||||
permalink(permalink: string, { filepath }) {
|
||||
if (permalink) return permalink
|
||||
const locale = resolveLocale(filepath)
|
||||
return path.join(locale, articlePrefix, nanoid(), '/')
|
||||
return normalizePath(
|
||||
path.join(locale, articlePrefix, nanoid(), '/')
|
||||
)
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user