IntegrationsVuepress

Add Search Bar to VuePress

Integrate Inkeep's search bar into your VuePress documentation for powerful content discovery.

What is VuePress

VuePress a markdown-centered static site generator.

Get an API key

Follow these steps to create an API key for your web integration.

Load the script files

  1. Navigate to the .vuepress directory
  2. Add the below scripts to the config.js file:
config.js
export default {
  head: [
    [
      "script",
      {
        src: "https://cdn.jsdelivr.net/npm/@inkeep/cxkit-js@0.5/dist/embed.js",
        type: "module",
        defer: true,
        onLoad: "initializeInkeep()",
      },
    ],
    ["script", { src: "js/addInkeep.js", type: "module", defer: true }],
  ],
};

Create the addInkeep.js script

Create an addInkeep.js file in your public/js folder.

touch public/js/addInkeep.js

To create a container for the search bar component, navigate to your desired page and add the following code:

<ClientOnly>
  <div id="inkeepSearchBar"></div>
</ClientOnly>

Configure the component

Next, configure the Inkeep widget:

addInkeep.js
const initializeInkeep = () => {
  const addInkeepWidget = () => {
    const searchContainer = document.querySelector("#inkeepSearchBar");
 
    if (!searchContainer) return;
 
    const inkeepWiddget = Inkeep.SearchBar("#inkeepSearchBar", {
      baseSettings: {
        apiKey: "INKEEP_API_KEY", // required
        primaryBrandColor: "#26D6FF",
        organizationDisplayName: "Inkeep",
        colorMode: {
          sync: {
            target: document.documentElement,
            attributes: ["data-md-color-scheme"],
            isDarkMode: (attributes) =>
              !!["dark", "dracula"].includes(
                attributes["data-md-color-scheme"]
              ),
          },
        },
      },
    });
  };
 
  if (document.readyState === "loading") {
    document.addEventListener("DOMContentLoaded", addInkeepWidget);
 
    return;
  }
 
  addInkeepWidget();
};

For a full list of customizations, check out the Search Bar documentation.

On this page