Update lib/mdx/getFiles to only return files with mdx extension.

This commit is contained in:
2024-08-14 15:26:13 +12:00
parent 0ba437ec88
commit fd45c146b6

View File

@ -26,8 +26,12 @@ const root = process.cwd()
export function getFiles(type) {
const prefixPaths = path.join(root, 'data', type)
const files = getAllFilesRecursively(prefixPaths)
// Filter to include only files with .mdx extension
const mdxFiles = files.filter(file => file.endsWith('.mdx'));
// Only want to return workshop/path and ignore root, replace is needed to work on Windows
return files.map((file) => file.slice(prefixPaths.length + 1).replace(/\\/g, '/'));
return mdxFiles.map((file) => file.slice(prefixPaths.length + 1).replace(/\\/g, '/'));
}
export function formatSlug(slug) {