import{isObject as s}from"../../../../utils/guards/is-object.js";const f=async({context:e})=>{const a={raw:[],aggregated:{}},r=e.fs.scan(/\.(md|page\.tsx?)$/);for(const t of r){if(t.isVirtual||await e.isPathIgnored(t.relativePath))continue;const o=t.relativePath.endsWith(".md")?"markdown-frontmatter":"react-frontmatter",{data:{frontmatter:n}}=await e.cache.load(t.relativePath,o);s(n)&&Object.keys(n).length&&(i(a.aggregated,n),a.raw.push(n))}return{version:"2",name:"frontmatterUsage",value:JSON.stringify(a)}};function i(e,a,r=""){for(const t in a)e[`${r}${t}`]=(e[`${r}${t}`]||0)+1,!(!s(a[t])||Array.isArray(a[t]))&&i(e,a[t],`${r}${t}_`)}export{f as getFrontmatterUsage};
