function injectPluginNavBar(inputString, packageJson, pluginDir, isLocal) {
  const codeLink = `https://github.com/google/blockly-samples/blob/master/plugins/${pluginDir}`;
  const npmLink = `https://www.npmjs.com/package/${packageJson.name}`;
  const baseURL = isLocal ? '/' : '/blockly-samples/';

  const navBar = `
  <!-- NAV BAR -->
  <nav id="toolbar">
    <a href="${baseURL}" id="arrow-back">
      <i class="material-icons">close</i>
      <img src="https://blocklycodelabs.dev/images/logo_knockout.png" class="logo-devs"
        alt="Blockly logo" />
    </a>

    <div class="title-grow">
      <div class="title">${packageJson.name} Demo</div>
      <div class="subtitle">${packageJson.description}</div>
    </div>
    ${packageJson.version}

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

  const tabs = `
  <!-- PAGE TABS -->
  <ul id="tabs">
    <li>
      <a href="${baseURL}plugins/${pluginDir}/test/index">
        Playground
      </a>
    </li>
    <li>
      <a href="${baseURL}plugins/${pluginDir}/README">
        README
      </a>
    </li>
  </ul>
  <!-- END PAGE TABS -->`;

  // 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>
      ${tabs}
      `,
  );
  modifiedContent = modifiedContent.replace(/(<\/body>)/, `</main>$1`);
  return modifiedContent;
}
Inject nav bar HTML for a specific plugin at the beginning of the body.
@param {string} inputString The initial page HTML, as a string.
@param {!Object} packageJson The contents of the plugin's package.json.
@param {string} pluginDir The directory of the plugin that is currently
    being prepared.
@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.