Rocks Template




    
    

    api/notes/<%= note.getRelation("shareFavicon").value %>/download<% } else { %>../favicon.ico<% } %>">
    
    

    <% if (note.hasLabel("shareSwagger")) { %>
        
        
        
        
    <% } %>

    <% if (note.type === "text" || note.type === "book") { %>
        
    <% } %>
    <% for (const cssRelation of note.getRelations("shareCss")) { %>
        
    <% } %>
    <% for (const jsRelation of note.getRelations("shareJs")) { %>
        
    <% } %>
    <% if (note.hasLabel("shareDisallowRobotIndexing")) { %>
        
    <% } %>
    
    <%
        const pageTitle = `${note.title}${note.noteId !== subRoot.note.noteId ? ` - ${subRoot.note.title}` : ""}`;

        // Setup some key OpenGraph variables
        const openGraphColor = subRoot.note.getLabelValue("shareOpenGraphColor");
        const openGraphURL = subRoot.note.getLabelValue("shareOpenGraphURL");
        const openGraphDomain = subRoot.note.getLabelValue("shareOpenGraphDomain");
        let openGraphImage = subRoot.note.getLabelValue("shareOpenGraphImage");
        // Relation takes priority and requires some altering
        if (subRoot.note.hasRelation("shareOpenGraphImage")) {
            openGraphImage = `api/images/${subRoot.note.getRelation("shareOpenGraphImage").value}/image.png`;
        }
    %>
    <%= pageTitle %>
    
    ">
    
    
    
    
    ">
    
    
    
    
    
    
    ">
    
    
    

<%
const logoWidth = subRoot.note.getLabelValue("shareLogoWidth");
const logoHeight = subRoot.note.getLabelValue("shareLogoHeight");
const mobileLogoHeight = logoHeight && logoWidth ? 32 / (logoWidth / logoHeight) : "";
const shareRootLink = subRoot.note.hasLabel("shareRootLink") ? subRoot.note.getLabelValue("shareRootLink") : `./${subRoot.note.noteId}`;
const currentTheme = note.getLabel("shareTheme") === "light" ? "light" : "dark";
const themeClass = currentTheme === "light" ? " theme-light" : " theme-dark";
const headingRe = /()(.+?)(<\/h[1-6]>)/g;
const headingMatches = [...content.matchAll(headingRe)];
const slugify = (text) => text.toLowerCase().replace(/[^\w]/g, "-");
content = content.replaceAll(headingRe, (...match) => {
    match[0] = match[0].replace(match[3], `#${match[3]}`);
    return match[0];
});
%>

    

ck-content<% } %><% if (isEmpty) { %> no-content<% } %>">

<%= note.title %>

<% if (isEmpty && (!note.hasVisibleChildren() && note.type !== "book")) { %>

This note has no content.

<% } else { %> <%- content %> <% } %>
<% if (note.hasVisibleChildren() || note.type === "book") { %> <% } %>
<% if (headingMatches.length > 1) { const level = (m) => parseInt(m[1].replace(/[]+/g, "")); const toc = [ { level: level(headingMatches[0]), name: headingMatches[0][2], children: [] } ]; const last = (arr = toc) => arr[arr.length - 1]; const makeEntry = (m) => ({level: level(m), name: m[2], children: []}); const getLevelArr = (lvl, arr = toc) => { if (arr[0].level === lvl) return arr; const top = last(arr); return top.children.length ? getLevelArr(lvl, top.children) : top.children; }; for (let m = 1; m < headingMatches.length; m++) { const target = getLevelArr(level(headingMatches[m])); target.push(makeEntry(headingMatches[m])); } %>

On This Page#

    <% for (const entry of toc) { %> <%- include("toc_item", {entry}) %> <% } %>
<% } %>