markopress 0.0.20 → 0.0.22

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 e from"gray-matter";import r from"markdown-it";import{getMarkdownIt as t,preloadLanguages as a}from"./loader.js";import{resolveImageTagsInHtml as l}from"../image/tag.js";let n,c=null,g=!1;export async function renderMarkdown(r,u){if(c)!g&&u?.languages?.length&&(await a(u.languages),g=!0);else{const e={...u,markoTags:{enabled:!0,...u?.markoTags}};e.languages?.length&&await a(e.languages),c=await t(e),n=e,g=!0}const{data:i,content:m,excerpt:$}=e(r,{excerpt:!0,excerpt_separator:"\x3c!-- more --\x3e"});return{frontmatter:i,content:m,html:await l(c.render(m),{base:u?.base??void 0}),excerpt:$,headers:p(function(e){const r=[],t=e.replace(/```[\s\S]*?```/g,"").replace(/~~~[\s\S]*?~~~/g,"").replace(/^(\t| {4}).+$/gm,""),a=/^(#{1,6})\s+(.+)$/gm;let l;for(;null!==(l=a.exec(t));){const e=l[1].length,t=l[2].trim(),a=o(t),n=s(t);r.push({level:e,title:a,slug:n})}return r}(m))}}export function resetRendererCache(){c=null,n=void 0}export function getRendererInstance(){return c}function o(e){return e.replace(/`([^`]+)`/g,"$1").replace(/\*\*\*\+([^*]+)\*\*\+/g,"$1").replace(/___+([^_]+)___+/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/__([^_]+)__/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/_([^_]+)_/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]+\]/g,"$1").trim()}function p(e){const r=[],t=[];for(const a of e){const e={level:a.level,title:a.title,slug:a.slug,children:[]};for(;t.length>0&&t[t.length-1].level>=a.level;)t.pop();0===t.length?r.push(e):t[t.length-1].children.push(e),t.push(e)}return r}function s(e){return e.trim().replace(/([a-z])([A-Z])/g,"$1-$2").replace(/([0-9])([a-zA-Z])/g,"$1-$2").replace(/([a-zA-Z])([0-9])/g,"$1-$2").toLowerCase().replace(/\s+/g,"-").replace(/[^\w\u00A0-\uFFFF\-]+/g,"").replace(/^-+|-+$/g,"").replace(/-+/g,"-")}
1
+ import e from"gray-matter";import r from"markdown-it";import{getMarkdownIt as t,preloadLanguages as a}from"./loader.js";import{resolveImageTagsInHtml as l}from"../image/tag.js";let n,c=null,g=!1;export async function renderMarkdown(r,u){if(c)!g&&u?.languages?.length&&(await a(u.languages),g=!0);else{const e={...u,markoTags:{enabled:!0,...u?.markoTags}};c=await t(e),e.languages?.length&&await a(e.languages),n=e,g=!0}const{data:i,content:m,excerpt:$}=e(r,{excerpt:!0,excerpt_separator:"\x3c!-- more --\x3e"});return{frontmatter:i,content:m,html:await l(c.render(m),{base:u?.base??void 0}),excerpt:$,headers:p(function(e){const r=[],t=e.replace(/```[\s\S]*?```/g,"").replace(/~~~[\s\S]*?~~~/g,"").replace(/^(\t| {4}).+$/gm,""),a=/^(#{1,6})\s+(.+)$/gm;let l;for(;null!==(l=a.exec(t));){const e=l[1].length,t=l[2].trim(),a=o(t),n=s(t);r.push({level:e,title:a,slug:n})}return r}(m))}}export function resetRendererCache(){c=null,n=void 0}export function getRendererInstance(){return c}function o(e){return e.replace(/`([^`]+)`/g,"$1").replace(/\*\*\*\+([^*]+)\*\*\+/g,"$1").replace(/___+([^_]+)___+/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/__([^_]+)__/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/_([^_]+)_/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]+\]/g,"$1").trim()}function p(e){const r=[],t=[];for(const a of e){const e={level:a.level,title:a.title,slug:a.slug,children:[]};for(;t.length>0&&t[t.length-1].level>=a.level;)t.pop();0===t.length?r.push(e):t[t.length-1].children.push(e),t.push(e)}return r}function s(e){return e.trim().replace(/([a-z])([A-Z])/g,"$1-$2").replace(/([0-9])([a-zA-Z])/g,"$1-$2").replace(/([a-zA-Z])([0-9])/g,"$1-$2").toLowerCase().replace(/\s+/g,"-").replace(/[^\w\u00A0-\uFFFF\-]+/g,"").replace(/^-+|-+$/g,"").replace(/-+/g,"-")}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markopress",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
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",
@@ -0,0 +1,32 @@
1
+ <div class="content content-${$global.contentTypeClass}">
2
+ <theme-body-top/>
3
+ <div class="content-layout">
4
+ <div class="content-body">
5
+ <h1>${$global.title}</h1>
6
+ <if=$global.description>
7
+ <p class="description">${$global.description}</p>
8
+ </if>
9
+ <if=$global.date>
10
+ <p class="meta">Published: ${$global.date}</p>
11
+ </if>
12
+ <if=$global.author>
13
+ <p class="meta">By ${$global.author}</p>
14
+ </if>
15
+ <if=$global.tags>
16
+ <p class="meta">
17
+ <for|tag| of=$global.tags>
18
+ <span class="tag">${tag}</span>
19
+ </for>
20
+ </p>
21
+ </if>
22
+ <hr>
23
+ <${$global.contentComponent || {}}>
24
+ <div>No content</div>
25
+ </${$global.contentComponent || {}}>
26
+ </div>
27
+ <if=$global.toc>
28
+ <toc headers=$global.toc/>
29
+ </if>
30
+ </div>
31
+ <theme-body-bottom/>
32
+ </div>
@@ -0,0 +1,19 @@
1
+ <div class="content content-${$global.contentTypeClass}">
2
+ <theme-body-top/>
3
+ <div class="content-layout">
4
+ <div class="content-body">
5
+ <h1>${$global.title}</h1>
6
+ <if=$global.description>
7
+ <p class="description">${$global.description}</p>
8
+ </if>
9
+ <hr>
10
+ <${$global.contentComponent || {}}>
11
+ <div>No content</div>
12
+ </${$global.contentComponent || {}}>
13
+ </div>
14
+ <if=$global.toc>
15
+ <toc headers=$global.toc/>
16
+ </if>
17
+ </div>
18
+ <theme-body-bottom/>
19
+ </div>
@@ -0,0 +1,23 @@
1
+ <div class="content content-${$global.contentTypeClass}">
2
+ <theme-body-top/>
3
+ <${$global.contentComponent || {}}>
4
+ <div>No content</div>
5
+ </${$global.contentComponent || {}}>
6
+ <if=$global.registry?.root?.length>
7
+ <section class="recent-posts">
8
+ <h2>Recent Posts</h2>
9
+ <ul>
10
+ <for|post| of=$global.registry.root
11
+ .filter(post => post.metadata.date)
12
+ .sort((a, b) => new Date(b.metadata.date) - new Date(a.metadata.date))
13
+ .slice(0, 3)>
14
+ <li>
15
+ <a href=post.urlPath>${post.metadata.title || post.urlPath}</a>
16
+ <small>${new Date(post.metadata.date).toLocaleDateString()}</small>
17
+ </li>
18
+ </for>
19
+ </ul>
20
+ </section>
21
+ </if>
22
+ <theme-body-bottom/>
23
+ </div>
@@ -177,4 +177,8 @@ export async function GET(context, next) {
177
177
  if (frontmatter.tags) {
178
178
  context.tags = frontmatter.tags;
179
179
  }
180
+
181
+ // Layout resolution
182
+ context.layout = frontmatter.layout || contentType || 'page';
183
+ context.contentTypeClass = '{{CONTENT_TYPE_CLASS}}';
180
184
  }
@@ -1,120 +1,9 @@
1
- <div class="content {{CONTENT_TYPE_CLASS}}">
2
- <theme-body-top/>
3
- <div class="content-layout">
4
- <div class="content-body">
5
- <h1>${$global.title}</h1>
6
- <if=$global.description>
7
- <p class="description">${$global.description}</p>
8
- </if>
9
- <if=$global.date>
10
- <p class="meta">Published: ${$global.date}</p>
11
- </if>
12
- <if=$global.author>
13
- <p class="meta">By ${$global.author}</p>
14
- </if>
15
- <if=$global.tags>
16
- <p class="meta">
17
- <for|tag| of=$global.tags>
18
- <span class="tag">${tag}</span>
19
- </for>
20
- </p>
21
- </if>
22
- <hr>
23
- <${$global.contentComponent || {}}>
24
- <div>No content</div>
25
- </${$global.contentComponent || {}}>
26
- <if=$global.registry?.blog?.length>
27
- <section class="recent-posts">
28
- <h2>Recent Posts</h2>
29
- <ul>
30
- <for|post| of=$global.registry.blog>
31
- <if=post.metadata.date>
32
- <li>
33
- <a href=post.urlPath>${post.metadata.title || post.urlPath}</a>
34
- <small>${new Date(post.metadata.date).toLocaleDateString()}</small>
35
- </li>
36
- </if>
37
- </for>
38
- </ul>
39
- </section>
40
- </if>
41
- </div>
42
- <if=$global.toc>
43
- <toc headers=$global.toc/>
44
- </if>
45
- </div>
46
- <theme-body-bottom/>
47
- </div>
48
-
49
- <style>
50
- .content-layout {
51
- display: flex;
52
- gap: 32px;
53
- max-width: 1100px;
54
- margin: 0 auto;
55
- position: relative;
56
- }
57
-
58
- .content-body {
59
- flex: 1;
60
- min-width: 0;
61
- max-width: 100%;
62
- }
63
-
64
- .toc {
65
- position: sticky;
66
- top: 1rem;
67
- width: 200px;
68
- flex-shrink: 0;
69
- }
70
-
71
- .meta {
72
- font-size: 0.875rem;
73
- color: #666;
74
- }
75
-
76
- .tag {
77
- display: inline-block;
78
- background: #e5e7eb;
79
- padding: 0.125rem 0.5rem;
80
- border-radius: 4px;
81
- margin-right: 0.5rem;
82
- font-size: 0.75rem;
83
- }
84
-
85
- .recent-posts {
86
- margin-top: 2rem;
87
- padding-top: 1.5rem;
88
- border-top: 1px solid #e5e7eb;
89
- }
90
-
91
- .recent-posts h2 {
92
- margin-bottom: 0.75rem;
93
- }
94
-
95
- .recent-posts ul {
96
- list-style: none;
97
- padding: 0;
98
- }
99
-
100
- .recent-posts li {
101
- padding: 0.5rem 0;
102
- display: flex;
103
- justify-content: space-between;
104
- align-items: baseline;
105
- }
106
-
107
- .recent-posts li a {
108
- color: var(--color-primary-2, #3b82f6);
109
- text-decoration: none;
110
- }
111
-
112
- .recent-posts li a:hover {
113
- text-decoration: underline;
114
- }
115
-
116
- .recent-posts small {
117
- color: #6b7280;
118
- font-size: 0.8rem;
119
- }
120
- </style>
1
+ <if=$global.layout === 'blog'>
2
+ <blog-layout/>
3
+ </if>
4
+ <else if=$global.layout === 'root'>
5
+ <root-layout/>
6
+ </else>
7
+ <else>
8
+ <page-layout/>
9
+ </else>