daldridge / docusaurus-plugin-lunr

Docusaurus v2 plugin to create a local search index for use with Lunr.js
MIT License
50 stars 5 forks source link

Exception thrown if no versions.json is present #1

Open daldridge opened 4 years ago

daldridge commented 4 years ago

The React hook used to determine the current documentation version used a dynamic import with import(@site/versions.json'. The base Webpack config has an alias for @site, allowing the import to resolve as expected. However, if the versions file does not exist, an exception will be thrown, and the try/catch in the hook empirically is unable to handle it.

Maybe a custom Webpack resolver could be written to provide a default empty array if the file doesn't exist? (Just a hunch this might be possible... A custom loader won't work, as those only run when the file exists.)