function injectExampleNavBar(inputString, demoConfig, pageRoot, isLocal) {
  // Build up information from package.json.
  const descriptionString = demoConfig.description
    ? `<div class="subtitle">${demoConfig.description}</div>`
    : ``;
  const codeLink = `https://github.com/google/blockly-samples/blob/master/${pageRoot}`;

  const pages = demoConfig.pages;
  const tabString = pages ? createExampleTabs(pageRoot, pages, isLocal) : '';
  const indexURL = isLocal ? '/' : '/blockly-samples';
  // Assemble that information into a nav bar and tabs for getting to linked
  // example pages.
  const navBar = `
  <!-- NAV BAR -->
  <nav id="toolbar">
    <a href="${indexURL}" id="arrow-back">
      <i class="material-icons">close</i>
      <img src="https://blocklycodelabs.dev/images/logo_knockout.png" class="logo-devs"
        alt="Blockly sample" />
    </a>

    <div class="title-grow">
      <div class="title">${demoConfig.title}</div>
      ${descriptionString}
    </div>

    <a href="${codeLink}" class="button" target="_blank">View code</a>
  </nav>
  <!-- END NAV BAR -->`;

  // Find the start of the body and inject the nav bar just after the opening
  // <body> tag, preserving anything else in the tag (such as onload).
  // Also wrap all page content in a <main></main> tag.
  let modifiedContent = inputString.replace(
    /<body([^>]*)>/,
    `<body$1 class="root">
      ${navBar}
      <main id="main" class="has-tabs">
        <div class="drop-shadow"></div>
        ${tabString}
        `,
  );
  modifiedContent = modifiedContent.replace(/<\/body>/, `</main>\n  </body>`);
  return modifiedContent;
}
Inject nav bar HTML for a specific example at the beginning of the body.
@param {string} inputString The initial page HTML, as a string.
@param {!Object} demoConfig The contents of the blocklyDemoConfig object
    in the example's package.json.
@param {string} pageRoot The location of the example's files relative to
    the root of the repository.
@param {boolean} isLocal True if building for a local test. False if
    building for gh-pages.
@returns {string} The modified contents of the page, as a string.