nodality 1.0.148 → 1.0.150
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.
- package/layout/animator.js +1 -1
- package/layout/audio.js +1 -1
- package/layout/audionew.js +1 -1
- package/layout/base-2.js +1 -1
- package/layout/base.js +1 -1
- package/layout/beta-desktop-bar.js +1 -1
- package/layout/beta-mobile-bar.js +1 -1
- package/layout/box.js +1 -1
- package/layout/button.js +1 -1
- package/layout/cards.js +1 -1
- package/layout/center.js +1 -1
- package/layout/checkbox.js +1 -1
- package/layout/circle.js +1 -1
- package/layout/clean-row.js +1 -1
- package/layout/code.js +1 -1
- package/layout/container.js +1 -1
- package/layout/custom.js +1 -1
- package/layout/div-image.js +1 -1
- package/layout/dropdown-2025.js +1 -1
- package/layout/dropdown.js +1 -1
- package/layout/empty-element.js +1 -1
- package/layout/external-stylesheet.js +1 -1
- package/layout/flex-card.js +1 -1
- package/layout/flex-grid.js +1 -1
- package/layout/flex-row.js +1 -1
- package/layout/footer.js +1 -1
- package/layout/form-components/custom.js +1 -1
- package/layout/form-components/data-list.js +1 -1
- package/layout/form-components/floating-input.js +1 -1
- package/layout/form-components/form-all.js +1 -1
- package/layout/form-components/form.js +1 -1
- package/layout/form-components/image-picker.js +1 -1
- package/layout/form-components/picker.js +1 -1
- package/layout/form-components/radio.js +1 -1
- package/layout/form-components/radiogroup.js +1 -1
- package/layout/form-components/range.js +1 -1
- package/layout/free.js +1 -1
- package/layout/grid-new.js +1 -1
- package/layout/grid-switcher.js +1 -1
- package/layout/grid.js +1 -1
- package/layout/group.js +1 -1
- package/layout/header.js +1 -1
- package/layout/horizontal-scroller.js +1 -1
- package/layout/image-old.js +1 -1
- package/layout/image.js +1 -1
- package/layout/index.js +1 -1
- package/layout/label.js +1 -1
- package/layout/link.js +1 -1
- package/layout/list-OLD.js +1 -1
- package/layout/list.js +1 -1
- package/layout/meta-adder.js +1 -1
- package/layout/modal-2025.js +1 -1
- package/layout/modernwrap.js +1 -1
- package/layout/multiswitcher.js +1 -1
- package/layout/multiswitcherBeta.js +1 -1
- package/layout/nav-bar.js +1 -1
- package/layout/nav-factor/custom-div.js +1 -1
- package/layout/navBar-OLD.js +1 -1
- package/layout/new-flat-adder.js +1 -1
- package/layout/new-nav-bar.js +1 -1
- package/layout/offset-container.js +1 -1
- package/layout/polygon.js +1 -1
- package/layout/prerender.js +89 -4
- package/layout/progress.js +1 -1
- package/layout/row.js +1 -1
- package/layout/saved-new-nav-bar.js +1 -1
- package/layout/scroll-video.js +1 -1
- package/layout/side-bar.js +1 -1
- package/layout/side-nav-bar.js +1 -1
- package/layout/simple-bar.js +1 -1
- package/layout/slider-2025.js +1 -1
- package/layout/spacer.js +1 -1
- package/layout/stack.js +1 -1
- package/layout/styler.js +1 -1
- package/layout/svg.js +1 -1
- package/layout/switcher.js +1 -1
- package/layout/table.js +1 -1
- package/layout/text-field.js +1 -1
- package/layout/text.js +1 -1
- package/layout/ulist.js +1 -1
- package/layout/video.js +1 -1
- package/layout/without-new.js +1 -1
- package/layout/wrap.js +1 -1
- package/layout/zoom-card.js +1 -1
- package/lib/card-getter.js +1 -1
- package/lib/designer.js +1 -1
- package/lib/element-mapper.js +1 -1
- package/lib/keyframe-animation.js +1 -1
- package/lib/link-getter.js +1 -1
- package/lib/scroll-video.js +1 -1
- package/lib/stacker.js +1 -1
- package/lib/theme.js +1 -1
- package/lib/transform-anim.js +1 -1
- package/package.json +1 -1
package/layout/animator.js
CHANGED
package/layout/audio.js
CHANGED
package/layout/audionew.js
CHANGED
package/layout/base-2.js
CHANGED
package/layout/base.js
CHANGED
package/layout/box.js
CHANGED
package/layout/button.js
CHANGED
package/layout/cards.js
CHANGED
package/layout/center.js
CHANGED
package/layout/checkbox.js
CHANGED
package/layout/circle.js
CHANGED
package/layout/clean-row.js
CHANGED
package/layout/code.js
CHANGED
package/layout/container.js
CHANGED
package/layout/custom.js
CHANGED
package/layout/div-image.js
CHANGED
package/layout/dropdown-2025.js
CHANGED
package/layout/dropdown.js
CHANGED
package/layout/empty-element.js
CHANGED
package/layout/flex-card.js
CHANGED
package/layout/flex-grid.js
CHANGED
package/layout/flex-row.js
CHANGED
package/layout/footer.js
CHANGED
package/layout/free.js
CHANGED
package/layout/grid-new.js
CHANGED
package/layout/grid-switcher.js
CHANGED
package/layout/grid.js
CHANGED
package/layout/group.js
CHANGED
package/layout/header.js
CHANGED
package/layout/image-old.js
CHANGED
package/layout/image.js
CHANGED
package/layout/index.js
CHANGED
package/layout/label.js
CHANGED
package/layout/link.js
CHANGED
package/layout/list-OLD.js
CHANGED
package/layout/list.js
CHANGED
package/layout/meta-adder.js
CHANGED
package/layout/modal-2025.js
CHANGED
package/layout/modernwrap.js
CHANGED
package/layout/multiswitcher.js
CHANGED
package/layout/nav-bar.js
CHANGED
package/layout/navBar-OLD.js
CHANGED
package/layout/new-flat-adder.js
CHANGED
package/layout/new-nav-bar.js
CHANGED
package/layout/polygon.js
CHANGED
package/layout/prerender.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* nodality v1.0.
|
|
2
|
+
* nodality v1.0.150
|
|
3
3
|
* (c) 2026 Filip Vabrousek
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -120,6 +120,9 @@ export async function prerender({
|
|
|
120
120
|
localStorageKey = "h7lang",
|
|
121
121
|
url = "http://localhost/",
|
|
122
122
|
viewport = { width: 390, height: 844 },
|
|
123
|
+
htmlLang,
|
|
124
|
+
canonical,
|
|
125
|
+
alternates,
|
|
123
126
|
build,
|
|
124
127
|
output,
|
|
125
128
|
}) {
|
|
@@ -334,11 +337,93 @@ export async function prerender({
|
|
|
334
337
|
// promise-based for full coverage.
|
|
335
338
|
await new Promise((resolve) => setImmediate(resolve));
|
|
336
339
|
|
|
340
|
+
// ─── SEO head injection ─────────────────────────────────────────
|
|
341
|
+
//
|
|
342
|
+
// Inject per-locale `<html lang>`, `<link rel="canonical">`, and
|
|
343
|
+
// `<link rel="alternate" hreflang>` tags so search engines and
|
|
344
|
+
// social-share crawlers can attribute each prerendered file to
|
|
345
|
+
// its correct language and prevent duplicate-content rank
|
|
346
|
+
// collapse across locales.
|
|
347
|
+
//
|
|
348
|
+
// Doing this at the library level (rather than the consumer
|
|
349
|
+
// template) keeps every SSG site that uses `nodality/ssg`
|
|
350
|
+
// SEO-complete without each consumer reinventing the boilerplate.
|
|
351
|
+
|
|
352
|
+
if (htmlLang) {
|
|
353
|
+
window.document.documentElement.setAttribute("lang", htmlLang);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (canonical) {
|
|
357
|
+
// Remove any prior <link rel="canonical"> from the template so
|
|
358
|
+
// we don't end up with two competing canonicals after re-runs.
|
|
359
|
+
const prior = window.document.head.querySelector('link[rel="canonical"]');
|
|
360
|
+
if (prior) prior.remove();
|
|
361
|
+
const link = window.document.createElement("link");
|
|
362
|
+
link.setAttribute("rel", "canonical");
|
|
363
|
+
link.setAttribute("href", canonical);
|
|
364
|
+
window.document.head.appendChild(link);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (Array.isArray(alternates) && alternates.length > 0) {
|
|
368
|
+
// Strip prior hreflang alternates so successive prerender runs
|
|
369
|
+
// produce byte-identical output (idempotent build).
|
|
370
|
+
for (const el of window.document.head.querySelectorAll('link[rel="alternate"][hreflang]')) {
|
|
371
|
+
el.remove();
|
|
372
|
+
}
|
|
373
|
+
for (const alt of alternates) {
|
|
374
|
+
if (!alt || !alt.hreflang || !alt.href) continue;
|
|
375
|
+
const link = window.document.createElement("link");
|
|
376
|
+
link.setAttribute("rel", "alternate");
|
|
377
|
+
link.setAttribute("hreflang", alt.hreflang);
|
|
378
|
+
link.setAttribute("href", alt.href);
|
|
379
|
+
window.document.head.appendChild(link);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// ─── Hydration handoff ──────────────────────────────────────────
|
|
384
|
+
//
|
|
385
|
+
// The runtime <script> tags from the template still load in the
|
|
386
|
+
// live browser — they're how interactivity (dropdowns, animations,
|
|
387
|
+
// language switching) reaches the user. But Nodality's `render()`
|
|
388
|
+
// primitive APPENDS to the mount target rather than replacing it.
|
|
389
|
+
// That means without intervention, the browser would parse the
|
|
390
|
+
// prerendered DOM (visible), then app.js would run and append a
|
|
391
|
+
// SECOND copy of every section beneath it. The user sees the
|
|
392
|
+
// page rendered twice, stacked.
|
|
393
|
+
//
|
|
394
|
+
// Fix: inject a tiny inline `<script>` right BEFORE the first
|
|
395
|
+
// runtime module script. The inline script empties the mount
|
|
396
|
+
// container so app.js starts with a clean slate. Bots that don't
|
|
397
|
+
// execute JS still see the prerendered content (SEO + social
|
|
398
|
+
// preview win preserved). Users with JS see the prerendered
|
|
399
|
+
// content as instant-paint, then a sub-frame later the inline
|
|
400
|
+
// script clears mount and app.js rebuilds — visually a brief
|
|
401
|
+
// flicker, no duplication.
|
|
402
|
+
//
|
|
403
|
+
// Why not just have app.js clear mount itself: nodality has no
|
|
404
|
+
// hook for "before first render" and the page entry scripts in
|
|
405
|
+
// every consumer would each need the same boilerplate. Doing it
|
|
406
|
+
// here, once, keeps consumers untouched.
|
|
407
|
+
if (mount) {
|
|
408
|
+
const firstRuntimeScript = window.document.querySelector(
|
|
409
|
+
'body script[type="module"][src], body script[src][type="module"]'
|
|
410
|
+
);
|
|
411
|
+
if (firstRuntimeScript) {
|
|
412
|
+
const clearScript = window.document.createElement("script");
|
|
413
|
+
// Inline (not type="module") so it executes synchronously,
|
|
414
|
+
// before any module scripts begin loading. Module scripts
|
|
415
|
+
// are always deferred, so the clear runs in the right order
|
|
416
|
+
// regardless of where it sits in the DOM relative to them.
|
|
417
|
+
clearScript.textContent =
|
|
418
|
+
`(function(){var m=document.querySelector(${JSON.stringify(mount)});if(m)m.innerHTML='';})();`;
|
|
419
|
+
firstRuntimeScript.parentNode.insertBefore(clearScript, firstRuntimeScript);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
337
423
|
// Serialize the full document. `dom.serialize()` returns
|
|
338
424
|
// `<!DOCTYPE html><html>...</html>` including the template's
|
|
339
|
-
// head + the now-populated body
|
|
340
|
-
//
|
|
341
|
-
// re-execute app.js and re-mount on top of the static DOM.
|
|
425
|
+
// head + the now-populated body PLUS the hydration-clear script
|
|
426
|
+
// we injected above.
|
|
342
427
|
const rendered = dom.serialize();
|
|
343
428
|
|
|
344
429
|
// Ensure the output directory exists. Writing to a path like
|
package/layout/progress.js
CHANGED
package/layout/row.js
CHANGED
package/layout/scroll-video.js
CHANGED
package/layout/side-bar.js
CHANGED
package/layout/side-nav-bar.js
CHANGED
package/layout/simple-bar.js
CHANGED
package/layout/slider-2025.js
CHANGED
package/layout/spacer.js
CHANGED
package/layout/stack.js
CHANGED
package/layout/styler.js
CHANGED
package/layout/svg.js
CHANGED
package/layout/switcher.js
CHANGED
package/layout/table.js
CHANGED
package/layout/text-field.js
CHANGED
package/layout/text.js
CHANGED
package/layout/ulist.js
CHANGED
package/layout/video.js
CHANGED
package/layout/without-new.js
CHANGED
package/layout/wrap.js
CHANGED
package/layout/zoom-card.js
CHANGED
package/lib/card-getter.js
CHANGED
package/lib/designer.js
CHANGED
package/lib/element-mapper.js
CHANGED
package/lib/link-getter.js
CHANGED
package/lib/scroll-video.js
CHANGED
package/lib/stacker.js
CHANGED
package/lib/theme.js
CHANGED
package/lib/transform-anim.js
CHANGED