"use strict";const p=require("node:path"),u=require("node:fs");function y(t,n){const{isAsync:e,...r}=n;return e?d(t,r):h(t,r)}async function d(t,n){const e=await u.promises.readFile(t,"utf8");return i(e,n)}function h(t,n){const e=u.readFileSync(t,"utf8");return i(e,n)}function i(t,n){const{content:e,placeholder:r}=n;return t.replace(r,e)}function x(t={}){const{dir:n="layouts",name:e="default",placeholder:r=//}=t;return(l,o,f)=>{const c=o.matterDataPrefix,a=c?o[c]:o,s=typeof a.layout=="string"?a.layout:e,m=p.join(n,/\.html$/.test(s)?s:s+".html");return y(m,{content:l,placeholder:r,isAsync:f})}}module.exports=x;