diff --git a/src/content-linter/lib/helpers/utils.js b/src/content-linter/lib/helpers/utils.js index 637ce78915..f8c394b256 100644 --- a/src/content-linter/lib/helpers/utils.js +++ b/src/content-linter/lib/helpers/utils.js @@ -114,7 +114,7 @@ export const docsDomains = ['docs.github.com', 'help.github.com', 'developer.git // frontmatter properties. export function getFrontmatter(lines) { const fmString = lines.join('\n') - const data = matter(fmString).data + const { data } = matter(fmString) // If there is no frontmatter or the frontmatter contains // no keys, matter will return an empty object. if (Object.keys(data).length === 0) return null diff --git a/src/content-linter/lib/linting-rules/annotate-frontmatter.js b/src/content-linter/lib/linting-rules/annotate-frontmatter.js index fc4b7a8f33..316e84356d 100644 --- a/src/content-linter/lib/linting-rules/annotate-frontmatter.js +++ b/src/content-linter/lib/linting-rules/annotate-frontmatter.js @@ -1,5 +1,5 @@ import { addError, filterTokens } from 'markdownlint-rule-helpers' -import matter from 'gray-matter' +import { getFrontmatter } from '../helpers/utils.js' export const annotateFrontmatter = { names: ['GHD040', 'annotate-frontmatter'], @@ -10,8 +10,8 @@ export const annotateFrontmatter = { function: function GHD040(params, onError) { filterTokens(params, 'fence', (token) => { if (!token.info.includes('annotate')) return - const fm = matter(params.frontMatterLines.join('\n')).data - if (fm.layout && fm.layout === 'inline') return + const fm = getFrontmatter(params.frontMatterLines) + if (!fm || (fm.layout && fm.layout === 'inline')) return addError( onError,