fix: windows compatible file path
This commit is contained in:
parent
5e36f320df
commit
3c2720a84b
@ -27,8 +27,8 @@ const tokenClassNames = {
|
||||
export function getFiles(type) {
|
||||
const prefixPaths = path.join(root, 'data', type)
|
||||
const files = getAllFilesRecursively(prefixPaths)
|
||||
// Only want to return blog/path and ignore root
|
||||
return files.map((file) => file.slice(prefixPaths.length + 1))
|
||||
// Only want to return blog/path and ignore root, replace is needed to work on Windows
|
||||
return files.map((file) => file.slice(prefixPaths.length + 1).replace(/\\/g, '/'))
|
||||
}
|
||||
|
||||
export function formatSlug(slug) {
|
||||
@ -97,7 +97,8 @@ export async function getAllFilesFrontMatter(folder) {
|
||||
const allFrontMatter = []
|
||||
|
||||
files.forEach((file) => {
|
||||
const fileName = file.slice(prefixPaths.length + 1)
|
||||
// Replace is needed to work on Windows
|
||||
const fileName = file.slice(prefixPaths.length + 1).replace(/\\/g, '/')
|
||||
const source = fs.readFileSync(file, 'utf8')
|
||||
const { data } = matter(source)
|
||||
if (data.draft !== true) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user