mnfst-render 0.5.48 → 0.5.50

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.
@@ -1480,7 +1480,15 @@ function stripResolvedXIconDirectives(html) {
1480
1480
  }
1481
1481
 
1482
1482
  function markPrerenderedManifestComponents(html) {
1483
- return html.replace(/<(x-[a-z][\w-]*)([^>]*)>/gi, (full, tag, attrs) => {
1483
+ // x-if/x-for template content is authored source Alpine clones at runtime — never mark it.
1484
+ const templates = [];
1485
+ return html.replace(/<(\/?)template(?=[\s>])([^>]*)>|<(x-[a-z][\w-]*)([^>]*)>/gi, (full, close, tplAttrs, tag, attrs) => {
1486
+ if (!tag) {
1487
+ if (close) templates.pop();
1488
+ else templates.push(/\sx-(?:if|for)\s*=/i.test(tplAttrs || ''));
1489
+ return full;
1490
+ }
1491
+ if (templates.includes(true)) return full;
1484
1492
  const a = attrs || '';
1485
1493
  if (/\bdata-pre-rendered\s*=/i.test(a) || /\bdata-processed\s*=/i.test(a)) return full;
1486
1494
  // Inside an explicit hydrate island — the runtime will restore its
@@ -3116,7 +3124,8 @@ ${urlEntries.join('\n')}
3116
3124
 
3117
3125
  /**
3118
3126
  * Group llms entries into sections by first URL segment ("Blog" for /blog/*),
3119
- * root page as "Overview", in first-encounter order. Wherever a path holds two
3127
+ * root page as "Overview", in first-encounter order with each split section
3128
+ * placed directly after its parent. Wherever a path holds two
3120
3129
  * or more sub-areas that each have their own page and children, each sub-area
3121
3130
  * becomes its own section labelled by its page title, recursively: /docs/ai/*
3122
3131
  * and /docs/framework/* split into "AI Plugins" and "Framework", and groups
@@ -3180,7 +3189,21 @@ function groupLlmsSections(entries, siteName = '') {
3180
3189
  if (!sections.has(key)) sections.set(key, { label, entries: [] });
3181
3190
  sections.get(key).entries.push(entry);
3182
3191
  }
3183
- return sections;
3192
+ const keys = [...sections.keys()];
3193
+ const parentOf = (key) => keys.filter((k) => key.startsWith(k + '/')).sort((a, b) => b.length - a.length)[0];
3194
+ const kids = new Map();
3195
+ for (const key of keys) {
3196
+ const parent = parentOf(key) ?? '';
3197
+ if (!kids.has(parent)) kids.set(parent, []);
3198
+ kids.get(parent).push(key);
3199
+ }
3200
+ const ordered = new Map();
3201
+ const visit = (key) => {
3202
+ ordered.set(key, sections.get(key));
3203
+ for (const child of kids.get(key) || []) visit(child);
3204
+ };
3205
+ for (const key of kids.get('') || []) visit(key);
3206
+ return ordered;
3184
3207
  }
3185
3208
 
3186
3209
  /**
@@ -5173,7 +5196,7 @@ async function runPrerender(config) {
5173
5196
  let tagged = false;
5174
5197
  const lookup = tpl._x_lookup;
5175
5198
  if (lookup) {
5176
- try { Object.values(lookup).forEach((el) => { if (el) { tag(el); tagged = true; } }); } catch { /* not iterable */ }
5199
+ try { (lookup instanceof Map ? [...lookup.values()] : Object.values(lookup)).forEach((el) => { if (el) { tag(el); tagged = true; } }); } catch { /* not iterable */ }
5177
5200
  }
5178
5201
  if (tagged) return;
5179
5202
  const first = tpl.content && tpl.content.firstElementChild;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst-render",
3
- "version": "0.5.48",
3
+ "version": "0.5.50",
4
4
  "description": "Render Manifest sites to static HTML for SEO",
5
5
  "type": "module",
6
6
  "bin": {