scripts/doc-generator/generate_header_html.js
/**
 * Construct HTML element, as a string, which corresponds to the header for
 * the chosen documentation page.
 * @param {Object} config
 * @param {number} currentLinkIdx
 * @param {string} currentPath
 * @param {object} logoInfo
 * @returns {string}
 */
Construct HTML element, as a string, which corresponds to the header for
the chosen documentation page.
Construct HTML element as a string which corresponds to the header for the chosen documentation page .
function generateHeaderHtml(config, currentLinkIdx, currentPath, logoInfo) {
  const { versionInfo, links, linksRightIndex } = config;
  const hamburgerHtml = constructHamburgerMenuHtmlInHeaderBar();
  const logoHtml = constructLogoHtmlInHeaderBar(logoInfo);
  const currentDir = path.dirname(currentPath);
  const linksHtml = links.map((l, i) => {
    const customClass =
      i === linksRightIndex     ? " first-right" :
      i === linksRightIndex - 1 ? " last-left"   :
                                         "";
    switch (l.type) {
      case "local-doc": {
        const relativeUri = toUriCompatibleRelativePath(l.firstPage, currentDir);
        const activeClass = i === currentLinkIdx ? " navbar-active" : "";
        const cleanedHref = encode(relativeUri);
        return `<a class="navbar-item${activeClass}${customClass} hideable"` +
          `href="${cleanedHref}">${encode(l.displayName)}</a>`;
      }
      case "external-link": {
        const cleanedHref = encode(l.link);
        return `<a class="navbar-item${customClass} hideable"` +
          `href="${cleanedHref}">${encode(l.displayName)}</a>`;
      }
      case "github-link":
        return constructGithubLinkHtmlInHeaderBar(l.link, customClass);
      case "search":
        return constructSearchHtmlInHeaderBar(customClass);
      case "version":
        return constructVersionLinkHtmlInHeaderBar(versionInfo, customClass);
    }
  }).join("\n");
  return `<nav class="navbar-parent">` +
    `<div class="navbar-wrapper">` +
    `<div class="navbar-items">` +
    hamburgerHtml +
    logoHtml +
    linksHtml +
    "</div></div> </nav>";
}
function generateHeaderHtml ( config , currentLinkIdx , currentPath , logoInfo ) { const { versionInfo , links , linksRightIndex } = config ; const hamburgerHtml = constructHamburgerMenuHtmlInHeaderBar ( ) ; const logoHtml = constructLogoHtmlInHeaderBar ( logoInfo ) ; const currentDir = path . dirname ( currentPath ) ; const linksHtml = links . map ( ( l , i ) => { const customClass = i === linksRightIndex ? " first-right" : i === linksRightIndex - 1 ? " last-left" : "" ; switch ( l . type ) { case "local-doc" : { const relativeUri = toUriCompatibleRelativePath ( l . firstPage , currentDir ) ; const activeClass = i === currentLinkIdx ? " navbar-active" : "" ; const cleanedHref = encode ( relativeUri ) ; return ` ${ activeClass } ${ customClass } ` + ` ${ cleanedHref } ${ encode ( l . displayName ) } ` ; } case "external-link" : { const cleanedHref = encode ( l . link ) ; return ` ${ customClass } ` + ` ${ cleanedHref } ${ encode ( l . displayName ) } ` ; } case "github-link" : return constructGithubLinkHtmlInHeaderBar ( l . link , customClass ) ; case "search" : return constructSearchHtmlInHeaderBar ( customClass ) ; case "version" : return constructVersionLinkHtmlInHeaderBar ( versionInfo , customClass ) ; } } ) . join ( "\n" ) ; return ` ` + ` ` + ` ` + hamburgerHtml + logoHtml + linksHtml + "</div></div> </nav>" ; }
Construct HTML element, as a string, which corresponds to the header for
 the chosen documentation page.
Construct HTML element as a string which corresponds to the header for the chosen documentation page .