@uniweb/runtime 1.2.3 → 1.2.4
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/dist/ssr.js +18 -1
- package/dist/ssr.js.map +1 -1
- package/package.json +6 -4
- package/src/components/PageRenderer.jsx +2 -1
- package/src/head-meta.js +38 -0
- package/src/hooks/useHeadMeta.js +17 -1
- package/src/ssr-renderer.js +11 -6
package/dist/ssr.js
CHANGED
|
@@ -9,6 +9,7 @@ import { DEFAULT_ICON_BASE, iconUrl } from "@uniweb/core/icon-corpus";
|
|
|
9
9
|
import { buildTheme, FONT_LINKS_MARKER, buildSectionOverrides } from "@uniweb/theming";
|
|
10
10
|
import "@uniweb/core/services";
|
|
11
11
|
import "@uniweb/core/tracker";
|
|
12
|
+
import { pageMarkdownUrls } from "@uniweb/projections/markdown-urls";
|
|
12
13
|
import { escapeHtml } from "@uniweb/core/page-shell";
|
|
13
14
|
import { escapeHtml as escapeHtml2, foundationCssUrl, pageShell } from "@uniweb/core/page-shell";
|
|
14
15
|
import DataStore, { deriveCacheKey as deriveCacheKey$1 } from "@uniweb/core/datastore";
|
|
@@ -495,6 +496,20 @@ function documentTitle(pageTitle, siteName) {
|
|
|
495
496
|
const title = String(pageTitle);
|
|
496
497
|
return siteName ? `${title} | ${siteName}` : title;
|
|
497
498
|
}
|
|
499
|
+
const urlsOfPages = /* @__PURE__ */ new WeakMap();
|
|
500
|
+
function pageHeadMeta(page) {
|
|
501
|
+
return { ...page.getHeadMeta(), markdown: markdownUrlOf(page) };
|
|
502
|
+
}
|
|
503
|
+
function markdownUrlOf(page) {
|
|
504
|
+
const website = page?.website;
|
|
505
|
+
if (!website) return null;
|
|
506
|
+
let urls = urlsOfPages.get(website.pages);
|
|
507
|
+
if (!urls) {
|
|
508
|
+
urls = pageMarkdownUrls({ pages: website.getContentPages(), config: website.config });
|
|
509
|
+
urlsOfPages.set(website.pages, urls);
|
|
510
|
+
}
|
|
511
|
+
return urls.get(page.route) ?? null;
|
|
512
|
+
}
|
|
498
513
|
function resolvePage(website, route) {
|
|
499
514
|
return website.getPage(route);
|
|
500
515
|
}
|
|
@@ -805,7 +820,7 @@ ${options.sectionOverrideCSS}
|
|
|
805
820
|
return result;
|
|
806
821
|
}
|
|
807
822
|
function writeHeadMeta(html, page) {
|
|
808
|
-
const meta = typeof page?.getHeadMeta === "function" ? page
|
|
823
|
+
const meta = typeof page?.getHeadMeta === "function" ? pageHeadMeta(page) : { description: page?.description || null };
|
|
809
824
|
const end = html.indexOf("</head>");
|
|
810
825
|
if (!meta || end === -1) return html;
|
|
811
826
|
const og = meta.og || {};
|
|
@@ -838,6 +853,8 @@ function writeHeadMeta(html, page) {
|
|
|
838
853
|
for (const { hreflang, url } of meta.alternates || []) {
|
|
839
854
|
written.push(`<link rel="alternate" hreflang="${escapeHtml(hreflang)}" href="${escapeHtml(url)}">`);
|
|
840
855
|
}
|
|
856
|
+
head = head.replace(/<link\b(?=[^>]*\brel=["']alternate["'])(?=[^>]*\btype=["']text\/markdown["'])[^>]*>\s*/gi, "");
|
|
857
|
+
if (meta.markdown) written.push(`<link rel="alternate" type="text/markdown" href="${escapeHtml(meta.markdown)}">`);
|
|
841
858
|
return `${head}${written.join("\n")}
|
|
842
859
|
${html.slice(end)}`;
|
|
843
860
|
}
|