mdorigin 0.1.7 → 0.1.8

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.
@@ -78,15 +78,39 @@ export function extractManagedIndexEntries(markdown) {
78
78
  }
79
79
  const rawHref = entryMatch[2];
80
80
  const href = rewriteMarkdownHref(rawHref);
81
+ const explicitKind = extractManagedIndexKind(lines.slice(1));
81
82
  entries.push({
82
- kind: href.endsWith('/') ? 'directory' : 'article',
83
+ kind: explicitKind ?? (href.endsWith('/') ? 'directory' : 'article'),
83
84
  title: entryMatch[1],
84
85
  href,
85
- detail: lines[1]?.trim() || undefined,
86
+ detail: extractManagedIndexDetail(lines.slice(1)),
86
87
  });
87
88
  }
88
89
  return entries;
89
90
  }
91
+ function extractManagedIndexKind(lines) {
92
+ for (const line of lines) {
93
+ const trimmed = line.trim();
94
+ const match = trimmed.match(/^<!--\s*mdorigin:index\s+kind=(article|directory)\s*-->$/);
95
+ if (match) {
96
+ return match[1];
97
+ }
98
+ }
99
+ return undefined;
100
+ }
101
+ function extractManagedIndexDetail(lines) {
102
+ for (const line of lines) {
103
+ const trimmed = line.trim();
104
+ if (trimmed === '') {
105
+ continue;
106
+ }
107
+ if (/^<!--\s*mdorigin:index\s+kind=(article|directory)\s*-->$/.test(trimmed)) {
108
+ continue;
109
+ }
110
+ return trimmed;
111
+ }
112
+ return undefined;
113
+ }
90
114
  function normalizeMeta(data) {
91
115
  const meta = { ...data };
92
116
  if (typeof data.title === 'string') {
@@ -69,11 +69,17 @@ export function renderDocument(options) {
69
69
  const editLinkBlock = options.editLinkHref
70
70
  ? `<a class="site-footer__edit-link" href="${escapeHtml(options.editLinkHref)}">Edit this page</a>`
71
71
  : '';
72
+ const markdownViewBlock = options.alternateMarkdownPath
73
+ ? `<a class="site-footer__markdown-link" href="${escapeHtml(options.alternateMarkdownPath)}" aria-label="View Markdown source">MD View</a>`
74
+ : '';
75
+ const footerActionsBlock = markdownViewBlock || editLinkBlock
76
+ ? `<div class="site-footer__actions">${markdownViewBlock}${editLinkBlock}</div>`
77
+ : '';
72
78
  const footerTextBlock = options.footerText
73
79
  ? `<p class="site-footer__text">${escapeHtml(options.footerText)}</p>`
74
80
  : '';
75
- const footerMetaBlock = socialLinksBlock || editLinkBlock
76
- ? `<div class="site-footer__meta">${socialLinksBlock}${editLinkBlock}</div>`
81
+ const footerMetaBlock = socialLinksBlock || footerActionsBlock
82
+ ? `<div class="site-footer__meta">${socialLinksBlock}${footerActionsBlock}</div>`
77
83
  : '';
78
84
  const footerBlock = footerNavBlock || footerTextBlock || footerMetaBlock
79
85
  ? `<footer class="site-footer"><div class="site-footer__inner">${footerNavBlock}${footerTextBlock}${footerMetaBlock}</div></footer>`
@@ -254,6 +254,12 @@ main {
254
254
  justify-content: space-between;
255
255
  gap: 1rem;
256
256
  }
257
+ .site-footer__actions {
258
+ display: inline-flex;
259
+ align-items: center;
260
+ gap: 0.85rem;
261
+ flex-wrap: wrap;
262
+ }
257
263
  .site-footer__nav ul,
258
264
  .site-footer__social {
259
265
  list-style: none;
@@ -288,11 +294,13 @@ main {
288
294
  font-weight: 700;
289
295
  }
290
296
  .site-footer__text,
291
- .site-footer__edit-link {
297
+ .site-footer__edit-link,
298
+ .site-footer__markdown-link {
292
299
  display: block;
293
300
  margin-top: 0.9rem;
294
301
  }
295
- .site-footer__edit-link {
302
+ .site-footer__edit-link,
303
+ .site-footer__markdown-link {
296
304
  display: inline-block;
297
305
  margin-top: 0;
298
306
  font-size: 0.78rem;
@@ -556,6 +564,12 @@ main {
556
564
  justify-content: space-between;
557
565
  gap: 1rem;
558
566
  }
567
+ .site-footer__actions {
568
+ display: inline-flex;
569
+ align-items: center;
570
+ gap: 0.95rem;
571
+ flex-wrap: wrap;
572
+ }
559
573
  .site-footer__nav ul,
560
574
  .site-footer__social {
561
575
  list-style: none;
@@ -590,11 +604,13 @@ main {
590
604
  font-weight: 700;
591
605
  }
592
606
  .site-footer__text,
593
- .site-footer__edit-link {
607
+ .site-footer__edit-link,
608
+ .site-footer__markdown-link {
594
609
  display: block;
595
610
  margin-top: 0.95rem;
596
611
  }
597
- .site-footer__edit-link {
612
+ .site-footer__edit-link,
613
+ .site-footer__markdown-link {
598
614
  display: inline-block;
599
615
  margin-top: 0;
600
616
  font-size: 0.78rem;
@@ -859,6 +875,12 @@ main {
859
875
  justify-content: space-between;
860
876
  gap: 1rem;
861
877
  }
878
+ .site-footer__actions {
879
+ display: inline-flex;
880
+ align-items: center;
881
+ gap: 0.9rem;
882
+ flex-wrap: wrap;
883
+ }
862
884
  .site-footer__nav ul,
863
885
  .site-footer__social {
864
886
  list-style: none;
@@ -893,11 +915,13 @@ main {
893
915
  font-weight: 700;
894
916
  }
895
917
  .site-footer__text,
896
- .site-footer__edit-link {
918
+ .site-footer__edit-link,
919
+ .site-footer__markdown-link {
897
920
  display: block;
898
921
  margin-top: 0.9rem;
899
922
  }
900
- .site-footer__edit-link {
923
+ .site-footer__edit-link,
924
+ .site-footer__markdown-link {
901
925
  display: inline-block;
902
926
  margin-top: 0;
903
927
  font-size: 0.78rem;
@@ -167,6 +167,7 @@ function renderManagedIndexBlock(entries) {
167
167
  if (entry.detail) {
168
168
  lines.push(` ${entry.detail}`);
169
169
  }
170
+ lines.push(` <!-- mdorigin:index kind=${entry.kind} -->`);
170
171
  lines.push('');
171
172
  }
172
173
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdorigin",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "type": "module",
5
5
  "description": "Markdown-first publishing for humans and agents.",
6
6
  "repository": {