<%= note.title %>
<% if (isEmpty && (!note.hasVisibleChildren() && note.type !== "book")) { %><%= t("share_page.no-content") %>
<% } else { %> <% content = content.replace(/% const hasTree = subRoot.note.hasVisibleChildren(); // Collect HTML snippets by location const htmlSnippetsByLocation = {}; for (const htmlRelation of note.getRelations("shareHtml")) { const htmlNote = htmlRelation.targetNote; if (htmlNote) { let location = htmlNote.getLabelValue("shareHtmlLocation") || "content:end"; if (!location.includes(":")) { location = location + ":end"; } if (!htmlSnippetsByLocation[location]) { htmlSnippetsByLocation[location] = []; } htmlSnippetsByLocation[location].push(htmlNote.getContent()); } } const renderSnippets = (location) => { const snippets = htmlSnippetsByLocation[location]; return snippets ? snippets.join("\n") : ""; }; // ---- SEO: per-page URL / canonical / OG image / JSON-LD ---- const rootUrl = subRoot.note.getLabelValue("shareOpenGraphURL") || ""; const perNoteUrl = note.getLabelValue("shareOpenGraphURL"); const pageUrl = perNoteUrl || (rootUrl && note.noteId !== subRoot.note.noteId ? rootUrl + (note.shareId || note.noteId) : rootUrl); let ogImageRel = subRoot.note.getLabelValue("shareOpenGraphImage"); if (subRoot.note.hasRelation("shareOpenGraphImage")) { ogImageRel = `api/images/${subRoot.note.getRelation("shareOpenGraphImage").value}/image.png`; } const ogImage = ogImageRel ? rootUrl + ogImageRel : ""; const jsonLd = []; if (note.noteId === subRoot.note.noteId) { jsonLd.push({ "@context": "https://schema.org", "@type": "WebSite", name: subRoot.note.title, url: pageUrl, description: note.getLabelValue("shareDescription") || "" }); } else if (note.getLabelValue("publish") === "true") { jsonLd.push({ "@context": "https://schema.org", "@type": "BlogPosting", headline: note.title, url: pageUrl, datePublished: (note.getLabelValue("date") || note.dateCreated).slice(0, 10), dateModified: (note.utcDateModified || "").slice(0, 10), description: note.getLabelValue("shareDescription") || "", mainEntityOfPage: pageUrl, author: { "@type": "Person", name: subRoot.note.title } }); } else { jsonLd.push({ "@context": "https://schema.org", "@type": "CollectionPage", name: note.title, url: pageUrl, description: note.getLabelValue("shareDescription") || "" }); } %> <%- renderSnippets("head:start") %> <% for (const url of cssToLoad) { %> <% } %> <% for (const url of jsToLoad) { %> <% } %> <% if (note.hasLabel("shareDisallowRobotIndexing")) { %> <% } else { %> <% } %> <% const pageTitle = `${note.title}${note.noteId !== subRoot.note.noteId ? ` - ${subRoot.note.title}` : ""}`; const openGraphColor = subRoot.note.getLabelValue("shareOpenGraphColor"); const openGraphDomain = subRoot.note.getLabelValue("shareOpenGraphDomain"); %>
<%= t("share_page.no-content") %>
<% } else { %> <% content = content.replace(/