markopress 0.0.13 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{SitemapStream as t,streamToPromise as e}from"sitemap";import{promises as o}from"fs";import{join as r}from"path";function n(t,e){for(const o of e){const e=o.replace(/\*\*/g,".*").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]");if(RegExp(`^${e}$`).test(t))return!0}return!1}async function s(t){try{return(await o.stat(t)).mtime}catch(e){return void(e instanceof Error&&console.warn(`[sitemap] Warning: could not get mtime for ${t}: ${e.message}`))}}async function a(t,e){const o={url:t},r=e.getPages(),n=e.getDocs(),a=e.getPosts(),i=r.find(e=>e.urlPath===t);if(i){const t=await s(i.filePath);return t&&(o.lastmod=t),o}const c=n.find(e=>e.urlPath===t);if(c){const t=await s(c.filePath);return t&&(o.lastmod=t),o}const m=a.find(e=>e.urlPath===t);if(m){const t=await s(m.filePath);return t&&(o.lastmod=t),o}return o}export async function generateSitemap(s,i={}){const{config:c,outDir:m,allContent:f}=s;try{const m=function(t,e){if(e?.hostname)return e.hostname;const o=t.site;if(o.url)return o.url;throw Error("Sitemap hostname is required. Set site.url in config or provide hostname in sitemap options.")}(c,i),l=c.site?.base||"/",u=i.exclude||["/api/**","/admin/**"],p=r(c.root,".markopress","src",".generated","static-urls.json");let g=[];try{const t=await o.readFile(p,"utf-8");g=JSON.parse(t)}catch(t){console.warn("[sitemap] static-urls.json not found, sitemap may be incomplete")}const h=[];for(const t of g){if(n(t,u))continue;const e=`${m}${l}${t.replace(/^\//,"")}`,o=await a(t,f);o.url=e,h.push(o)}const d=i.transformItems?i.transformItems(h):h,w=new t({hostname:m,...i.sitemapOptions});for(const t of d)w.write(t);w.end();const P=await e(w).then(t=>t.toString()),$=s.outDir,y=r($,"public"),x=r(y,"sitemap.xml");await o.mkdir(y,{recursive:!0}),await o.writeFile(x,P,"utf8"),console.log(`[seo] Generated sitemap.xml with ${d.length} URLs`)}catch(t){const e=t instanceof Error?t.message:t+"";console.error("[seo] Failed to generate sitemap: "+e)}}
1
+ import{SitemapStream as t,streamToPromise as e}from"sitemap";import{promises as o}from"fs";import{join as n}from"path";function r(t,e){for(const o of e){const e=o.replace(/\*\*/g,".*").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]");if(RegExp(`^${e}$`).test(t))return!0}return!1}async function s(t){try{return(await o.stat(t)).mtime}catch(e){return void(e instanceof Error&&console.warn(`[sitemap] Warning: could not get mtime for ${t}: ${e.message}`))}}async function a(t,e){const o={url:t},n=e.getPages(),r=e.getDocs(),a=e.getPosts(),i=n.find(e=>e.urlPath===t);if(i){const t=await s(i.filePath);return t&&(o.lastmod=t),o}const c=r.find(e=>e.urlPath===t);if(c){const t=await s(c.filePath);return t&&(o.lastmod=t),o}const m=a.find(e=>e.urlPath===t);if(m){const t=await s(m.filePath);return t&&(o.lastmod=t),o}return o}export async function generateSitemap(s,i={}){const{config:c,outDir:m,allContent:l}=s;try{let m=function(t,e){if(e?.hostname)return e.hostname;const o=t.site;if(o.url)return o.url;throw Error("Sitemap hostname is required. Set site.url in config or provide hostname in sitemap options.")}(c,i);m.endsWith("/")&&(m=m.slice(0,-1));const f=c.site?.base||"/",u=i.exclude||["/api/**","/admin/**"],p=n(c.root,".markopress","src",".generated","static-urls.json");let h=[];try{const t=await o.readFile(p,"utf-8");h=JSON.parse(t)}catch(t){console.warn("[sitemap] static-urls.json not found, sitemap may be incomplete")}const d=[];for(const t of h){if(r(t,u))continue;const e=`${m}${f}${t.replace(/^\//,"")}`,o=await a(t,l);o.url=e,d.push(o)}const g=i.transformItems?i.transformItems(d):d,w=new t({hostname:m,...i.sitemapOptions});for(const t of g)w.write(t);w.end();const P=await e(w).then(t=>t.toString()),$=s.outDir,y=n($,"public"),x=n(y,"sitemap.xml");await o.mkdir(y,{recursive:!0}),await o.writeFile(x,P,"utf8"),console.log(`[seo] Generated sitemap.xml with ${g.length} URLs`)}catch(t){const e=t instanceof Error?t.message:t+"";console.error("[seo] Failed to generate sitemap: "+e)}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markopress",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "A fast, modern static site generator built on Marko.js v6 - drop-in alternative to VitePress and Docusaurus with full content compatibility",
5
5
  "keywords": [
6
6
  "static-site-generator",