From f29fa8102022dc6b45dec49e6fb76e9836deefba Mon Sep 17 00:00:00 2001 From: Filip Harald Date: Fri, 13 Sep 2024 07:09:24 +0200 Subject: [PATCH] Adding local search with `@cmfcmf`-plugin (#78) --- README.md | 13 ++++- docusaurus.config.js | 10 +++- package-lock.json | 133 ++++++++++++++++++++++++++++++++++++++++++- package.json | 1 + 4 files changed, 152 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 619e4fa..9348ec2 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,17 @@ npm install npm run start ``` +### Run docs with search feature enabled + +Instead of `npm run start`, you'll need to: + +```bash +npm run docusaurus build +npm run docusaurus serve +``` + +If you change the [search configuration](/docusaurus.config.js#L27), you'll need to run `npm run docusaurus build` and then `npm run docusaurus serve` again to refresh with the changes. + ## Contribution Guidelines Thank you for your interest in contributing to improve the documentation! @@ -40,7 +51,7 @@ If you find anything that is confusing or can be improved in an existing documen When **adding a new page**, you need to fork the repository, create a new branch, and make all changes necessary in your repository. Once you are done with your changes, create a PR to Scaffold-ETH 2 Documentation repository. -Add the new pages to the `docs` folder, placing them in the specific directory where you want the page to be shown. +Add the new pages to the `docs` folder, placing them in the specific directory where you want the page to be shown. **Siderbar** link will get **autogenerated** under your specific folder, in the **position** that you specify in your document header. Example: ```markdown diff --git a/docusaurus.config.js b/docusaurus.config.js index 2ad7a7d..4b41f26 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -20,7 +20,15 @@ const config = { // If you aren't using GitHub pages, you don't need these. organizationName: "scaffold-eth", projectName: "scaffold-eth-2", - + plugins: [ + [ + require.resolve("@cmfcmf/docusaurus-search-local"), + { + indexBlog: false, + includeParentCategoriesInPageTitle: true, + }, + ], + ], scripts: [ { src: "https://plausible.io/js/plausible.js", diff --git a/package-lock.json b/package-lock.json index 1a7b2b0..26bbb8b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "se-2", "version": "0.0.0", "dependencies": { + "@cmfcmf/docusaurus-search-local": "^1.2.0", "@docusaurus/core": "2.4.0", "@docusaurus/preset-classic": "2.4.0", "@mdx-js/react": "^1.6.22", @@ -32,6 +33,72 @@ "@algolia/autocomplete-shared": "1.8.2" } }, + "node_modules/@algolia/autocomplete-js": { + "version": "1.17.4", + "resolved": "https://registry.npmjs.org/@algolia/autocomplete-js/-/autocomplete-js-1.17.4.tgz", + "integrity": "sha512-ANhINMwusKmsW/xHhgiKvUSLis/Lll9OilueBR9h/lxBlgEJ/hHIOTnZupzksyna1OtGZaW5keAu04E19+CW1w==", + "dependencies": { + "@algolia/autocomplete-core": "1.17.4", + "@algolia/autocomplete-preset-algolia": "1.17.4", + "@algolia/autocomplete-shared": "1.17.4", + "htm": "^3.1.1", + "preact": "^10.13.2" + }, + "peerDependencies": { + "@algolia/client-search": ">= 4.5.1 < 6", + "algoliasearch": ">= 4.9.1 < 6" + } + }, + "node_modules/@algolia/autocomplete-js/node_modules/@algolia/autocomplete-core": { + "version": "1.17.4", + "resolved": "https://registry.npmjs.org/@algolia/autocomplete-core/-/autocomplete-core-1.17.4.tgz", + "integrity": "sha512-H1CAzj43RDeC4Vq9FW2JLtRDNxhjRG/aPX69nbNrKbYzX9P0YohxrEj3kJ9G+e20y0L0pYboAOeU6wgbKJ6gOA==", + "dependencies": { + "@algolia/autocomplete-plugin-algolia-insights": "1.17.4", + "@algolia/autocomplete-shared": "1.17.4" + } + }, + "node_modules/@algolia/autocomplete-js/node_modules/@algolia/autocomplete-preset-algolia": { + "version": "1.17.4", + "resolved": "https://registry.npmjs.org/@algolia/autocomplete-preset-algolia/-/autocomplete-preset-algolia-1.17.4.tgz", + "integrity": "sha512-ijYn6hAGr3luVBVYDubaX600KXolVJH6yZlpeWZ9CNCEewgKIQ9ok3eNGha9EEJ0s9REYbp1TmDQ3T1I1aqcBA==", + "dependencies": { + "@algolia/autocomplete-shared": "1.17.4" + }, + "peerDependencies": { + "@algolia/client-search": ">= 4.9.1 < 6", + "algoliasearch": ">= 4.9.1 < 6" + } + }, + "node_modules/@algolia/autocomplete-js/node_modules/@algolia/autocomplete-shared": { + "version": "1.17.4", + "resolved": "https://registry.npmjs.org/@algolia/autocomplete-shared/-/autocomplete-shared-1.17.4.tgz", + "integrity": "sha512-AM7KntpKinDZGVYfZ4j8zt5ymgYBRXOZg0CFEeHLmViqu5BvQzzoc1aoNHQx6lBjViGckBYP9szA+t2QzRXy3A==", + "peerDependencies": { + "@algolia/client-search": ">= 4.9.1 < 6", + "algoliasearch": ">= 4.9.1 < 6" + } + }, + "node_modules/@algolia/autocomplete-plugin-algolia-insights": { + "version": "1.17.4", + "resolved": "https://registry.npmjs.org/@algolia/autocomplete-plugin-algolia-insights/-/autocomplete-plugin-algolia-insights-1.17.4.tgz", + "integrity": "sha512-fPABTwZtfD83qAzwnMYjJQ6ohCK7XE2l2++H+dOtV76cCIsAYYAC1bO5DnCbIi6Ma+OkNOgB1jCPI5EYOEsSpg==", + "dependencies": { + "@algolia/autocomplete-shared": "1.17.4" + }, + "peerDependencies": { + "search-insights": ">= 1 < 3" + } + }, + "node_modules/@algolia/autocomplete-plugin-algolia-insights/node_modules/@algolia/autocomplete-shared": { + "version": "1.17.4", + "resolved": "https://registry.npmjs.org/@algolia/autocomplete-shared/-/autocomplete-shared-1.17.4.tgz", + "integrity": "sha512-AM7KntpKinDZGVYfZ4j8zt5ymgYBRXOZg0CFEeHLmViqu5BvQzzoc1aoNHQx6lBjViGckBYP9szA+t2QzRXy3A==", + "peerDependencies": { + "@algolia/client-search": ">= 4.9.1 < 6", + "algoliasearch": ">= 4.9.1 < 6" + } + }, "node_modules/@algolia/autocomplete-preset-algolia": { "version": "1.8.2", "resolved": "https://registry.npmjs.org/@algolia/autocomplete-preset-algolia/-/autocomplete-preset-algolia-1.8.2.tgz", @@ -49,6 +116,11 @@ "resolved": "https://registry.npmjs.org/@algolia/autocomplete-shared/-/autocomplete-shared-1.8.2.tgz", "integrity": "sha512-b6Z/X4MczChMcfhk6kfRmBzPgjoPzuS9KGR4AFsiLulLNRAAqhP+xZTKtMnZGhLuc61I20d5WqlId02AZvcO6g==" }, + "node_modules/@algolia/autocomplete-theme-classic": { + "version": "1.17.4", + "resolved": "https://registry.npmjs.org/@algolia/autocomplete-theme-classic/-/autocomplete-theme-classic-1.17.4.tgz", + "integrity": "sha512-HK72OAhj0R5yYwjEO97gae+WbI7zsGeItl0Awo4H7b9VsYW5RyS4Z9EpO+WiWbYITu1EVz3mu2A6Vh/gNEszOg==" + }, "node_modules/@algolia/cache-browser-local-storage": { "version": "4.17.0", "resolved": "https://registry.npmjs.org/@algolia/cache-browser-local-storage/-/cache-browser-local-storage-4.17.0.tgz", @@ -1969,6 +2041,31 @@ "node": ">=6.9.0" } }, + "node_modules/@cmfcmf/docusaurus-search-local": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@cmfcmf/docusaurus-search-local/-/docusaurus-search-local-1.2.0.tgz", + "integrity": "sha512-Tc0GhRBsfZAiB+f6BoPB8YCQap6JzzcDyJ0dLSCSzWQ6wdWvDlTBrHc1YqR8q8AZ+STRszL5eZpZFi5dbTCdYg==", + "dependencies": { + "@algolia/autocomplete-js": "^1.8.2", + "@algolia/autocomplete-theme-classic": "^1.8.2", + "@algolia/client-search": "^4.12.0", + "algoliasearch": "^4.12.0", + "cheerio": "^1.0.0-rc.9", + "clsx": "^1.1.1", + "lunr-languages": "^1.4.0", + "mark.js": "^8.11.1", + "tslib": "^2.6.3" + }, + "peerDependencies": { + "@docusaurus/core": "^2.0.0", + "nodejieba": "^2.5.0" + }, + "peerDependenciesMeta": { + "nodejieba": { + "optional": true + } + } + }, "node_modules/@colors/colors": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", @@ -6752,6 +6849,11 @@ "safe-buffer": "~5.1.0" } }, + "node_modules/htm": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/htm/-/htm-3.1.1.tgz", + "integrity": "sha512-983Vyg8NwUE7JkZ6NmOqpCZ+sh1bKv2iYTlUkzlWmA5JD2acKoxd4KVxbMmxX/85mtfdnDmTFoNKcg5DGAvxNQ==" + }, "node_modules/html-entities": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.3.3.tgz", @@ -7691,6 +7793,11 @@ "yallist": "^3.0.2" } }, + "node_modules/lunr-languages": { + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/lunr-languages/-/lunr-languages-1.14.0.tgz", + "integrity": "sha512-hWUAb2KqM3L7J5bcrngszzISY4BxrXn/Xhbb9TTCJYEGqlR1nG67/M14sp09+PTIRklobrn57IAxcdcO/ZFyNA==" + }, "node_modules/make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -7713,6 +7820,11 @@ "semver": "bin/semver.js" } }, + "node_modules/mark.js": { + "version": "8.11.1", + "resolved": "https://registry.npmjs.org/mark.js/-/mark.js-8.11.1.tgz", + "integrity": "sha512-1I+1qpDt4idfgLQG+BNWmrqku+7/2bi5nLf4YwF8y8zXvmfiTBY3PV3ZibfrjBueCByROpuBjLLFCajqkgYoLQ==" + }, "node_modules/markdown-escapes": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/markdown-escapes/-/markdown-escapes-1.0.4.tgz", @@ -9149,6 +9261,15 @@ "postcss": "^8.2.15" } }, + "node_modules/preact": { + "version": "10.23.2", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.23.2.tgz", + "integrity": "sha512-kKYfePf9rzKnxOAKDpsWhg/ysrHPqT+yQ7UW4JjdnqjFIeNUnNcEJvhuA8fDenxAGWzUqtd51DfVg7xp/8T9NA==", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/preact" + } + }, "node_modules/prepend-http": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", @@ -10346,6 +10467,12 @@ "url": "https://opencollective.com/webpack" } }, + "node_modules/search-insights": { + "version": "2.16.2", + "resolved": "https://registry.npmjs.org/search-insights/-/search-insights-2.16.2.tgz", + "integrity": "sha512-+KrS5rnYlyWgzoCNJGsNPw7Vv+47Y7Ze7KZ+/9Xls+5BUugEbU2yv1n9JsQOqv+MLKYfg3bxI5K6tYJxXZY8FA==", + "peer": true + }, "node_modules/section-matter": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/section-matter/-/section-matter-1.0.0.tgz", @@ -11274,9 +11401,9 @@ } }, "node_modules/tslib": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", - "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==" + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" }, "node_modules/type-fest": { "version": "2.19.0", diff --git a/package.json b/package.json index 4a8d1b9..0737d7a 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "format-check": "npx prettier --check '**/*.{js,jsx,md,mdx,json,css}'" }, "dependencies": { + "@cmfcmf/docusaurus-search-local": "^1.2.0", "@docusaurus/core": "2.4.0", "@docusaurus/preset-classic": "2.4.0", "@mdx-js/react": "^1.6.22",