Milestone admin and frontend stage
This commit is contained in:
@@ -78,6 +78,11 @@ function isExternalHref(value) {
|
||||
return /^(https?:)?\/\//i.test(String(value || "")) || /^(mailto:|tel:)/i.test(String(value || ""));
|
||||
}
|
||||
|
||||
function isInertHref(value) {
|
||||
const href = String(value || "").trim();
|
||||
return !href || href === "#" || href === "#hero" || href.toLowerCase().startsWith("javascript:");
|
||||
}
|
||||
|
||||
function normalizeLinkForRender(item) {
|
||||
if (!item || typeof item !== "object") return;
|
||||
|
||||
@@ -103,12 +108,28 @@ function normalizeLinkForRender(item) {
|
||||
item.resolvedTarget = mode === "href" ? linkTarget : "";
|
||||
}
|
||||
|
||||
function normalizeDockItemForRender(item) {
|
||||
if (!item || typeof item !== "object") return;
|
||||
|
||||
const href = String(item.href || "").trim();
|
||||
const opensWindow = !isInertHref(href);
|
||||
|
||||
item.resolvedDockHref = href || "#";
|
||||
item.resolvedDockTarget = opensWindow ? "_blank" : "";
|
||||
item.resolvedDockRel = opensWindow ? "noopener noreferrer" : "";
|
||||
}
|
||||
|
||||
function applyRenderableLinks(model) {
|
||||
const staticLinks = model.staticElements?.content?.navigation?.links;
|
||||
if (Array.isArray(staticLinks)) {
|
||||
staticLinks.forEach(normalizeLinkForRender);
|
||||
}
|
||||
|
||||
const dockItems = model.staticElements?.content?.dock?.items;
|
||||
if (Array.isArray(dockItems)) {
|
||||
dockItems.forEach(normalizeDockItemForRender);
|
||||
}
|
||||
|
||||
for (const block of allBlocks(model)) {
|
||||
const footer = block.content?.footer;
|
||||
if (!footer) continue;
|
||||
|
||||
Reference in New Issue
Block a user