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) {
metadataPath: (mdxPath) => {
const aliasedSource = utils_1.aliasedSitePath(mdxPath, siteDir);
return path_1.default.join(dataDir, `${utils_1.docuHash(aliasedSource)}.json`);
},
},
metadataPath: (mdxPath: string) => {
const aliasedSource = aliasedSitePath(mdxPath, siteDir);
return path.join(
dataDir,
`${docuHash(aliasedSource)}.json`,
);
},
},
await Promise.all(highlightFiles.map(async (relativeSource) => {
const source = path_1.default.join(highlightDir, relativeSource);
const aliasedSource = utils_1.aliasedSitePath(source, siteDir);
const fileString = await fs_extra_1.default.readFile(source, 'utf-8');
const readingStats = reading_time_1.default(fileString);
const { frontMatter, content, excerpt } = utils_1.parse(fileString);
const fileName = path_1.default.basename(relativeSource);
const fileNameMatch = fileName.match(FILENAME_PATTERN);
if (frontMatter.draft && process.env.NODE_ENV === 'production') {
return;
}
let date = fileNameMatch ? new Date(fileNameMatch[1]) : new Date(Date.now());
let description = frontMatter.description || excerpt;
let id = frontMatter.id || frontMatter.title;
let linkName = relativeSource.replace(/\.mdx?$/, '');
let tags = frontMatter.tags || [];
let title = frontMatter.title || linkName;
highlights.push({
id: id,
metadataPath: (mdxPath) => {
const aliasedPath = aliasedSitePath(mdxPath, siteDir);
return path.join(
dataDir,
`${docuHash(aliasedPath)}.json`,
);
},
},
highlightFiles.map(async (relativeSource: string) => {
const source = path.join(highlightDir, relativeSource);
const aliasedSource = aliasedSitePath(source, siteDir);
const fileString = await fs.readFile(source, 'utf-8');
const readingStats = readingTime(fileString);
const {frontMatter, content, excerpt} = parse(fileString);
const fileName = path.basename(relativeSource);
const fileNameMatch = fileName.match(FILENAME_PATTERN);
if (frontMatter.draft && process.env.NODE_ENV === 'production') {
return;
}
let date = fileNameMatch ? new Date(fileNameMatch[1]) : new Date(Date.now());
let description = frontMatter.description || excerpt;
let id = frontMatter.id || frontMatter.title;
let linkName = relativeSource.replace(/\.mdx?$/, '');
let tags = frontMatter.tags || [];
let title = frontMatter.title || linkName;