import { isMobile } from '../util/env.js'; /** * Render github corner * @param {Object} data URL for the View Source on Github link * @param {String} cornerExternalLinkTarget value of the target attribute of the link * @return {String} SVG element as string */ export function corner(data, cornerExternalLinkTarget) { if (!data) { return ''; } if (!/\/\//.test(data)) { data = 'https://github.com/' + data; } data = data.replace(/^git\+/, ''); // Double check cornerExternalLinkTarget = cornerExternalLinkTarget || '_blank'; return /* html */ ` `; } /** * Renders main content * @param {Object} config Configuration object * @returns {String} HTML of the main content */ export function main(config) { const { hideSidebar, name } = config; // const name = config.name ? config.name : ''; const aside = /* html */ hideSidebar ? '' : `
${ config.name ? /* html */ `

${ config.logo ? `${name}` : name }

` : '' }
`; return /* html */ `
${aside}
`; } /** * Cover Page * @returns {String} Cover page */ export function cover() { return /* html */ `
`; } /** * Render tree * @param {Array} toc Array of TOC section links * @param {String} tpl TPL list * @return {String} Rendered tree */ export function tree( toc, tpl = /* html */ '
    {inner}
', ) { if (!toc || !toc.length) { return ''; } let innerHTML = ''; toc.forEach(node => { const title = node.title.replace(/(<([^>]+)>)/g, ''); innerHTML += /* html */ `
  • ${node.title}
  • `; if (node.children) { innerHTML += tree(node.children, tpl); } }); return tpl.replace('{inner}', innerHTML); } export function helper(className, content) { return /* html */ `

    ${content.slice(5).trim()}

    `; } /** * @deprecated */ export function theme(color) { return /* html */ ``; }