import*as l from"path";import{MARKDOC_PARTIALS_DATA_KEY as m}from"../../../store.js";import{isPartial as f}from"../is-partial.js";function p(t,r){return Promise.all(t.map(r)).then(i=>t.filter((s,e)=>i[e]))}async function h(t,r){const{markdown:i}=await t.getConfig(),s=i?.partialsFolders??[],e=await p(await t.fs.scan(/\.md$/),async a=>!(!l.posix.basename(a.relativePath).endsWith(".md")||await t.isPathIgnored(a.relativePath)||!f(a.relativePath,s)));r.setGlobalConfig({[m]:Object.fromEntries(e.map(a=>[a.relativePath,{}]))});const o={};for(const a of e){const{ast:n}=await r.parseMarkdoc(a,t);o[a.relativePath]=n}return o}export{h as prepareMarkdocPartials};
