Remove Unexpected File

This commit is contained in:
Teng 2021-06-18 18:12:12 +08:00
parent c0d2b8e542
commit b930f53e7c

View File

@ -98,6 +98,10 @@ export async function getAllFilesFrontMatter(folder) {
files.forEach((file) => {
// Replace is needed to work on Windows
const fileName = file.slice(prefixPaths.length + 1).replace(/\\/g, '/')
// Remove Unexpected File
if (path.extname(fileName) !== '.md' && path.extname(fileName) !== '.mdx') {
return
}
const source = fs.readFileSync(file, 'utf8')
const { data } = matter(source)
if (data.draft !== true) {