mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-23 22:00:38 -04:00
14 lines
462 B
JavaScript
14 lines
462 B
JavaScript
const matter = require('gray-matter');
|
|
|
|
const checkFrontmatter = (fullPath, isTranslation, content) => {
|
|
const { data: frontmatter } = matter(content);
|
|
let errors = [];
|
|
if (!frontmatter || _.isEmpty(frontmatter) || !frontmatter.title) {
|
|
errors.push(`${fullPath} is missing \`title key\` frontmatter.`);
|
|
}
|
|
if (isTranslation && !frontmatter.localeTitle) {
|
|
errors.push(`${fullPath} is missing \`localeTitle\`frontmatter.`);
|
|
}
|
|
return errors;
|
|
}
|