diff --git a/package-lock.json b/package-lock.json index eff5f89..064b25e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,6 +45,7 @@ "@types/react-dom": "18.2.7", "autoprefixer": "^10.4.14", "eslint": "^8.46.0", + "pagefind": "^1.0.4", "postcss": "^8.4.27", "prettier": "^3.0.1", "prettier-plugin-astro": "^0.11.0", @@ -2143,6 +2144,71 @@ "node": ">= 8" } }, + "node_modules/@pagefind/darwin-arm64": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@pagefind/darwin-arm64/-/darwin-arm64-1.0.4.tgz", + "integrity": "sha512-2OcthvceX2xhm5XbgOmW+lT45oLuHqCmvFeFtxh1gsuP5cO8vcD8ZH8Laj4pXQFCcK6eAdSShx+Ztx/LsQWZFQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@pagefind/darwin-x64": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@pagefind/darwin-x64/-/darwin-x64-1.0.4.tgz", + "integrity": "sha512-xkdvp0D9Ld/ZKsjo/y1bgfhTEU72ITimd2PMMQtts7jf6JPIOJbsiErCvm37m/qMFuPGEq/8d+fZ4pydOj08HQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@pagefind/linux-arm64": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@pagefind/linux-arm64/-/linux-arm64-1.0.4.tgz", + "integrity": "sha512-jGBrcCzIrMnNxLKVtogaQyajVfTAXM59KlBEwg6vTn8NW4fQ6nuFbbhlG4dTIsaamjEM5e8ZBEAKZfTB/qd9xw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@pagefind/linux-x64": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@pagefind/linux-x64/-/linux-x64-1.0.4.tgz", + "integrity": "sha512-LIn/QcvcEtLEBqKe5vpSbSC2O3fvqbRCWOTIklslqSORisCsvzsWbP6j+LYxE9q0oWIfkdMoWV1vrE/oCKRxHg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@pagefind/windows-x64": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@pagefind/windows-x64/-/windows-x64-1.0.4.tgz", + "integrity": "sha512-QlBCVeZfj9fc9sbUgdOz76ZDbeK4xZihOBAFqGuRJeChfM8pnVeH9iqSnXgO3+m9oITugTf7PicyRUFAG76xeQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@pkgr/utils": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/@pkgr/utils/-/utils-2.4.2.tgz", @@ -6907,6 +6973,22 @@ "node": ">=6" } }, + "node_modules/pagefind": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/pagefind/-/pagefind-1.0.4.tgz", + "integrity": "sha512-oRIizYe+zSI2Jw4zcMU0ebDZm27751hRFiSOBLwc1OIYMrsZKk+3m8p9EVaOmc6zZdtqwwdilNUNxXvBeHcP9w==", + "dev": true, + "bin": { + "pagefind": "lib/runner/bin.cjs" + }, + "optionalDependencies": { + "@pagefind/darwin-arm64": "1.0.4", + "@pagefind/darwin-x64": "1.0.4", + "@pagefind/linux-arm64": "1.0.4", + "@pagefind/linux-x64": "1.0.4", + "@pagefind/windows-x64": "1.0.4" + } + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", diff --git a/package.json b/package.json index ae31e81..fb53d78 100755 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "scripts": { "dev": "astro dev", "build": "astro build", + "postbuild": "pagefind --site dist", "format": "prettier -w ./src" }, "dependencies": { @@ -47,6 +48,7 @@ "@types/react-dom": "18.2.7", "autoprefixer": "^10.4.14", "eslint": "^8.46.0", + "pagefind": "^1.0.4", "postcss": "^8.4.27", "prettier": "^3.0.1", "prettier-plugin-astro": "^0.11.0", diff --git a/src/layouts/components/DocBrowser.astro b/src/layouts/components/DocBrowser.astro index b24faab..c6d71d3 100644 --- a/src/layouts/components/DocBrowser.astro +++ b/src/layouts/components/DocBrowser.astro @@ -1,7 +1,7 @@ --- import docs from "@/config/docs.json"; const { currentPage } = Astro.props; -const currentPageMatch = currentPage.slice(1); +const currentPageMatch = currentPage ? currentPage.slice(1) : null; const isCurrentPage = (item) => { if (item.link) { diff --git a/src/layouts/components/DocContents.astro b/src/layouts/components/DocContents.astro index ec29fd5..591a4cc 100644 --- a/src/layouts/components/DocContents.astro +++ b/src/layouts/components/DocContents.astro @@ -4,30 +4,30 @@ const { headings } = Astro.props; diff --git a/src/layouts/components/Header.astro b/src/layouts/components/Header.astro index efd654d..b70e6f5 100644 --- a/src/layouts/components/Header.astro +++ b/src/layouts/components/Header.astro @@ -2,7 +2,7 @@ import ThemeSwitcher from "@/components/ThemeSwitcher.astro"; import config from "@/config/config.json"; import menu from "@/config/menu.json"; -import { IoSearch } from "react-icons/io5/index.js"; +import { IoSearch, IoClose } from "react-icons/io5/index.js"; export interface ChildNavigationLink { name: string; @@ -100,18 +100,86 @@ const { pathname } = Astro.url; }
+ { settings.search && ( - - - + // + // + // + <> +
+ +
+