From 8983746f0ede409e2ffb68e4ed58f8b46bbf847b Mon Sep 17 00:00:00 2001 From: liyunze <50455574+liyunze-coding@users.noreply.github.com> Date: Fri, 22 Mar 2024 14:01:45 +0800 Subject: [PATCH] added pagefind for search --- .gitignore | 3 + README.md | 2 +- astro.config.mjs | 1 - package-lock.json | 125 +++++++++++++++----- package.json | 7 +- src/components/blocks/BlogPostPreview.astro | 2 +- src/components/blocks/Hero.astro | 2 +- src/components/blocks/TableOfContent.astro | 44 +++---- src/components/blocks/navBar.astro | 89 +++++++------- src/components/blocks/verticalNav.astro | 2 +- src/components/ui/SearchModal.astro | 55 +++++++++ src/layouts/BlogsLayout.astro | 10 -- src/layouts/Layout.astro | 42 ++----- src/pages/blog/index.astro | 2 +- src/pages/get-started/introduction.md | 4 +- tsconfig.json | 8 +- 16 files changed, 246 insertions(+), 152 deletions(-) create mode 100644 src/components/ui/SearchModal.astro diff --git a/.gitignore b/.gitignore index 6d4c0aa..5bb3aad 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,6 @@ pnpm-debug.log* # macOS-specific files .DS_Store + +# PageFind +public/pagefind \ No newline at end of file diff --git a/README.md b/README.md index f043871..c5badcb 100644 --- a/README.md +++ b/README.md @@ -54,5 +54,5 @@ This website is deployed on Vercel, which is a
  • Coworking Crew for providing resources
  • A Coworking Streamer Cheat Sheet as an amazing resource
  • MohFocus for the resources (bots and widgets)
  • -
  • RyanPython for building the website
  • +
  • RythonDev for building the website
  • diff --git a/astro.config.mjs b/astro.config.mjs index e0042b6..0344ea7 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -2,7 +2,6 @@ import { defineConfig } from "astro/config"; import tailwind from "@astrojs/tailwind"; import mdx from "@astrojs/mdx"; import react from "@astrojs/react"; - import expressiveCode from "astro-expressive-code"; // https://astro.build/config diff --git a/package-lock.json b/package-lock.json index 93c831e..d15119b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,10 +22,11 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "tailwind-merge": "^2.2.1", - "tailwindcss": "^3.4.1" + "tailwindcss": "^3.4.1", + "typescript": "^5.4.3" }, "devDependencies": { - "@types/react-router-dom": "^5.3.3", + "pagefind": "^1.0.4", "prettier": "^3.2.5", "prettier-plugin-tailwindcss": "^0.5.11" } @@ -1475,6 +1476,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/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", @@ -1719,12 +1785,6 @@ "@types/unist": "*" } }, - "node_modules/@types/history": { - "version": "4.7.11", - "resolved": "https://registry.npmjs.org/@types/history/-/history-4.7.11.tgz", - "integrity": "sha512-qjDJRrmvBMiTx+jyLxvLfJU7UznFuokDv4f3WRuriHKERccVpFU+8XMQUAbDzoiJCsmexxRExQeMwwCdamSKDA==", - "dev": true - }, "node_modules/@types/mdast": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.3.tgz", @@ -1794,27 +1854,6 @@ "@types/react": "*" } }, - "node_modules/@types/react-router": { - "version": "5.1.20", - "resolved": "https://registry.npmjs.org/@types/react-router/-/react-router-5.1.20.tgz", - "integrity": "sha512-jGjmu/ZqS7FjSH6owMcD5qpq19+1RS9DeVRqfl1FeBMxTDQAGwlMWOcs52NDoXaNKyG3d1cYQFMs9rCrb88o9Q==", - "dev": true, - "dependencies": { - "@types/history": "^4.7.11", - "@types/react": "*" - } - }, - "node_modules/@types/react-router-dom": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/@types/react-router-dom/-/react-router-dom-5.3.3.tgz", - "integrity": "sha512-kpqnYK4wcdm5UaWI3fLcELopqLrHgLqNsdpHauzlQktfkHL3npOSwtj1Uz9oKBAzs7lFtVkV8j83voAz2D8fhw==", - "dev": true, - "dependencies": { - "@types/history": "^4.7.11", - "@types/react": "*", - "@types/react-router": "*" - } - }, "node_modules/@types/scheduler": { "version": "0.16.8", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.8.tgz", @@ -5693,6 +5732,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/parse-entities": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-4.0.1.tgz", @@ -7916,6 +7971,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/typescript": { + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.3.tgz", + "integrity": "sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/ultrahtml": { "version": "1.5.3", "resolved": "https://registry.npmjs.org/ultrahtml/-/ultrahtml-1.5.3.tgz", diff --git a/package.json b/package.json index 72f849e..36695b5 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "dev": "astro dev --open", "start": "astro dev", - "build": "astro build", + "build": "astro build && pagefind --site dist && copy -r dist/pagefind public/", "preview": "astro preview", "astro": "astro" }, @@ -24,10 +24,11 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "tailwind-merge": "^2.2.1", - "tailwindcss": "^3.4.1" + "tailwindcss": "^3.4.1", + "typescript": "^5.4.3" }, "devDependencies": { - "@types/react-router-dom": "^5.3.3", + "pagefind": "^1.0.4", "prettier": "^3.2.5", "prettier-plugin-tailwindcss": "^0.5.11" } diff --git a/src/components/blocks/BlogPostPreview.astro b/src/components/blocks/BlogPostPreview.astro index e4decb0..68f4f60 100644 --- a/src/components/blocks/BlogPostPreview.astro +++ b/src/components/blocks/BlogPostPreview.astro @@ -35,7 +35,7 @@ const { title, tagline, pubDate, url } = Astro.props;
    +
    diff --git a/src/components/blocks/TableOfContent.astro b/src/components/blocks/TableOfContent.astro index b923572..6e9629d 100644 --- a/src/components/blocks/TableOfContent.astro +++ b/src/components/blocks/TableOfContent.astro @@ -1,31 +1,35 @@ --- type Heading = { - depth: number; - text: string; - slug: string; + depth: number; + text: string; + slug: string; }; const { headings } = Astro.props; ---

    - Table of Contents + Table of Contents

    - { - headings.map((heading: Heading, index: number) => { - if (heading.depth === 1) return; - const margin = `${heading.depth - 1.5}rem`; - return ( - - ); - }) - } + { + headings.map((heading: Heading, index: number) => { + if (heading.depth === 1) return; + const margin = `${heading.depth - 1.5}rem`; + return ( + + ); + }) + }
    diff --git a/src/components/blocks/navBar.astro b/src/components/blocks/navBar.astro index 593a5a3..782cf5a 100644 --- a/src/components/blocks/navBar.astro +++ b/src/components/blocks/navBar.astro @@ -1,11 +1,11 @@ --- import VerticalNav from "./verticalNav.astro"; +import SearchModal from "../ui/SearchModal.astro"; ---
    -
    + + diff --git a/src/components/blocks/verticalNav.astro b/src/components/blocks/verticalNav.astro index 25a8070..0c1c18f 100644 --- a/src/components/blocks/verticalNav.astro +++ b/src/components/blocks/verticalNav.astro @@ -66,7 +66,7 @@ const { showHome } = Astro.props; ---
    -
    diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 53158d8..9e4001a 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -20,6 +20,8 @@ const { title, description } = Astro.props; + + @@ -30,6 +32,14 @@ const { title, description } = Astro.props;
    + - diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro index 46e5d50..a044582 100644 --- a/src/pages/blog/index.astro +++ b/src/pages/blog/index.astro @@ -15,7 +15,7 @@ const allPosts = await getCollection("posts"); { allPosts.map((post) => ( Multi Task Widget +Multi Task Widget -If you want to add a task widget to your own stream, check it out in the Widgets section! +If you want to add a task widget to your own stream, check it out in the Widgets section! A task widget is a widget where users can use commands such as: - !task [current task] diff --git a/tsconfig.json b/tsconfig.json index 032ad64..6d0d384 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,6 +2,12 @@ "extends": "astro/tsconfigs/strict", "compilerOptions": { "jsx": "react-jsx", - "jsxImportSource": "react" + "jsxImportSource": "react", + "baseUrl": ".", + "paths": { + "@/*": [ + "./src/*" + ] + } } } \ No newline at end of file