canary
canary copied to clipboard
import from `@generated/pagefind/pagefind` in `@getcanary/docusaurus-pagefind`
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");
},
};
}