Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
guideFiles.map(async (relativeSource) => {
const source = path.join(guideDir, relativeSource);
const aliasedSource = aliasedSitePath(source, siteDir);
const guideFileName = path.basename(relativeSource);
const fileString = await fs.readFile(source, 'utf-8');
const {frontMatter, excerpt} = parseMarkdownString(fileString);
let date;
// Extract date and title from filename.
const match = guideFileName.match(FILENAME_PATTERN);
let linkName = guideFileName.replace(/\.mdx?$/, '');
if (match) {
const [, dateString, name] = match;
date = new Date(dateString);
linkName = name;
}
// Prefer user-defined date.
if (frontMatter.date) {
date = new Date(frontMatter.date);
}
// Use file create time for guide.
date = date || (await fs.stat(source)).birthtime;
fs.readdirSync(dir).forEach(function (file) {
if ( !/about\.mdx?/.test(file) ) {
let name = file.split('.').slice(0, -1).join('.');
let data = fs.readFileSync(path.join(dir, file));
const {frontMatter} = parseMarkdownString(data);
frontMatter["name"] = name;
components.push(frontMatter);
}
});
return components;