markopress 0.0.11 → 0.0.12
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($,"sitemap.xml");await o.mkdir(
|
|
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)}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markopress",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
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",
|
|
@@ -1 +1,16 @@
|
|
|
1
1
|
<!-- Extension point: theme head bottom -->
|
|
2
|
+
<!-- Renders head tags with position="bottom" from config.site.head -->
|
|
3
|
+
|
|
4
|
+
<if=$global.headBottom && $global.headBottom.length>
|
|
5
|
+
<for|tag| of=$global.headBottom>
|
|
6
|
+
<if=tag.length === 3>
|
|
7
|
+
<!-- Inline content tag: [tagName, attrs, content] -->
|
|
8
|
+
<${tag[0]} ...tag[1]>
|
|
9
|
+
${tag[2]}
|
|
10
|
+
</${tag[0]}>
|
|
11
|
+
<else>
|
|
12
|
+
<!-- Self-closing tag: [tagName, attrs] -->
|
|
13
|
+
<${tag[0]} ...tag[1]/>
|
|
14
|
+
</if>
|
|
15
|
+
</for>
|
|
16
|
+
</if>
|
|
@@ -1 +1,16 @@
|
|
|
1
1
|
<!-- Extension point: theme head top -->
|
|
2
|
+
<!-- Renders head tags with position="top" from config.site.head -->
|
|
3
|
+
|
|
4
|
+
<if=$global.headTop && $global.headTop.length>
|
|
5
|
+
<for|tag| of=$global.headTop>
|
|
6
|
+
<if=tag.length === 3>
|
|
7
|
+
<!-- Inline content tag: [tagName, attrs, content] -->
|
|
8
|
+
<${tag[0]} ...tag[1]>
|
|
9
|
+
${tag[2]}
|
|
10
|
+
</${tag[0]}>
|
|
11
|
+
<else>
|
|
12
|
+
<!-- Self-closing tag: [tagName, attrs] -->
|
|
13
|
+
<${tag[0]} ...tag[1]/>
|
|
14
|
+
</if>
|
|
15
|
+
</for>
|
|
16
|
+
</if>
|
|
@@ -129,6 +129,10 @@ export async function GET(context, next) {
|
|
|
129
129
|
context.footer = config.theme.options.footer || null;
|
|
130
130
|
context.hasComponentStyles = !!(config.markdown?.markoTags?.enabled);
|
|
131
131
|
|
|
132
|
+
// Head injection from plugin
|
|
133
|
+
context.headTop = config._headInject?.headTop || [];
|
|
134
|
+
context.headBottom = config._headInject?.headBottom || [];
|
|
135
|
+
|
|
132
136
|
context.title = frontmatter.title || slug;
|
|
133
137
|
context.description = frontmatter.description || '';
|
|
134
138
|
context.contentComponent = contentComponent;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>${$global.title || 'MarkoPress Site'}</title>
|
|
7
|
-
<if=$global.description>
|
|
8
|
-
<meta name="description" content=$global.description>
|
|
9
|
-
</if>
|
|
10
|
-
<link rel="stylesheet" href="/theme.css">
|
|
11
|
-
</head>
|
|
12
|
-
<body>
|
|
13
|
-
<div class="app-container">
|
|
14
|
-
<!-- Navbar -->
|
|
15
|
-
<nav class="navbar">
|
|
16
|
-
<div class="navbar-container">
|
|
17
|
-
<a href="/" class="navbar-brand">
|
|
18
|
-
<span class="navbar-title">MarkoPress Site</span>
|
|
19
|
-
</a>
|
|
20
|
-
<if=$global.navbar>
|
|
21
|
-
<nav class="navbar-nav">
|
|
22
|
-
<for|item| of=$global.navbar>
|
|
23
|
-
<a href=item.link class="nav-link">${item.text}</a>
|
|
24
|
-
</for>
|
|
25
|
-
</nav>
|
|
26
|
-
</if>
|
|
27
|
-
</div>
|
|
28
|
-
</nav>
|
|
29
|
-
|
|
30
|
-
<!-- Main content area with optional sidebar -->
|
|
31
|
-
<div class="main-wrapper">
|
|
32
|
-
<if=$global.sidebar>
|
|
33
|
-
<!-- Sidebar for docs -->
|
|
34
|
-
<aside class="sidebar">
|
|
35
|
-
<nav class="sidebar-nav">
|
|
36
|
-
<for|item| of=$global.sidebar>
|
|
37
|
-
<a href=item.link class="sidebar-link">${item.text}</a>
|
|
38
|
-
</for>
|
|
39
|
-
</nav>
|
|
40
|
-
</aside>
|
|
41
|
-
</if>
|
|
42
|
-
|
|
43
|
-
<!-- Page content -->
|
|
44
|
-
<main class="main-content">
|
|
45
|
-
<${input.content}/>
|
|
46
|
-
</main>
|
|
47
|
-
</div>
|
|
48
|
-
|
|
49
|
-
<!-- Footer -->
|
|
50
|
-
<footer class="footer">
|
|
51
|
-
<div class="footer-container">
|
|
52
|
-
<p>© 2024 MarkoPress Site. Built with MarkoPress.</p>
|
|
53
|
-
</div>
|
|
54
|
-
</footer>
|
|
55
|
-
</div>
|
|
56
|
-
</body>
|
|
57
|
-
</html>
|