canary icon indicating copy to clipboard operation
canary copied to clipboard

import from `@generated/pagefind/pagefind` in `@getcanary/docusaurus-pagefind`

Open yujonglee opened this issue 6 months ago • 1 comments

export default function plugin(_context, options) {
  const { indexOnly = false } = options;

  let generatedPath = null;

  const config = {
    name: "docusaurus-plugin-pagefind-canary",
    async contentLoaded({ actions }) {
      actions.setGlobalData({ options });
    },
+    configureWebpack(config) {
+      generatedPath = config.resolve.alias["@generated"];
+      return {};
+    },
    async postBuild({ routesPaths = [], outDir, baseUrl }) {
      const docs = getFilePaths(routesPaths, outDir, baseUrl, options);
+      await buildIndex(generatedPath, docs);
    },
  };

  if (indexOnly) {
    return config;
  }

  return {
    ...config,
    getThemePath() {
      return path.resolve(__dirname, "./theme");
    },
  };
}

yujonglee avatar Jul 29 '24 11:07 yujonglee