From e5b8bd7ab026e526a3c999f9950e5c04826a9857 Mon Sep 17 00:00:00 2001 From: Guoqi Sun Date: Tue, 26 Nov 2024 22:17:48 +0800 Subject: [PATCH] feat: complete header and footer components and dark/light mode switching function --- .vscode/extensions.json | 6 ++- .vscode/settings.json | 5 +++ package.json | 1 + pnpm-lock.yaml | 12 ++++++ src/components/astro/footer.astro | 22 ++++++++++ src/components/astro/header.astro | 17 ++++++++ src/components/astro/theme-toggle.astro | 57 +++++++++++++++++++++++++ src/components/{ => react}/test.tsx | 0 src/config.ts | 28 ++++++++++++ src/layouts/Layout.astro | 13 ------ src/layouts/base.astro | 42 ++++++++++++++++++ src/layouts/home.astro | 9 ++++ src/pages/index.astro | 12 ++++-- src/styles/globals.css | 27 ++++++++++++ tailwind.config.mjs | 1 + tsconfig.json | 1 - 16 files changed, 234 insertions(+), 19 deletions(-) create mode 100644 src/components/astro/footer.astro create mode 100644 src/components/astro/header.astro create mode 100644 src/components/astro/theme-toggle.astro rename src/components/{ => react}/test.tsx (100%) create mode 100644 src/config.ts delete mode 100644 src/layouts/Layout.astro create mode 100644 src/layouts/base.astro create mode 100644 src/layouts/home.astro create mode 100644 src/styles/globals.css diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 22a1505..832b4b2 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,4 +1,8 @@ { - "recommendations": ["astro-build.astro-vscode"], + "recommendations": [ + "astro-build.astro-vscode", + "esbenp.prettier-vscode", + "dbaeumer.vscode-eslint" + ], "unwantedRecommendations": [] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 33f4899..5b00e29 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,9 @@ { + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "[astro]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, "editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit", "source.organizeImports": "always" diff --git a/package.json b/package.json index 381cc97..b31576b 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", "astro": "^5.0.0-beta.10", + "lucide-react": "^0.461.0", "react": "^18.3.1", "react-dom": "^18.3.1", "tailwindcss": "^3.4.15", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bfe2edd..80bb830 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,6 +26,9 @@ importers: astro: specifier: ^5.0.0-beta.10 version: 5.0.0-beta.10(jiti@1.21.6)(rollup@4.27.4)(typescript@5.7.2)(yaml@2.6.1) + lucide-react: + specifier: ^0.461.0 + version: 0.461.0(react@18.3.1) react: specifier: ^18.3.1 version: 18.3.1 @@ -1991,6 +1994,11 @@ packages: lru-cache@5.1.1: resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} + lucide-react@0.461.0: + resolution: {integrity: sha512-Scpw3D/dV1bgVRC5Kh774RCm99z0iZpPv75M6kg7QL1lLvkQ1rmI1Sjjic1aGp1ULBwd7FokV6ry0g+d6pMB+w==} + peerDependencies: + react: ^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0-rc + magic-string@0.30.14: resolution: {integrity: sha512-5c99P1WKTed11ZC0HMJOj6CDIue6F8ySu+bJL+85q1zBEIY8IklrJ1eiKC2NDRh3Ct3FcvmJPyQHb9erXMTJNw==} @@ -5297,6 +5305,10 @@ snapshots: dependencies: yallist: 3.1.1 + lucide-react@0.461.0(react@18.3.1): + dependencies: + react: 18.3.1 + magic-string@0.30.14: dependencies: '@jridgewell/sourcemap-codec': 1.5.0 diff --git a/src/components/astro/footer.astro b/src/components/astro/footer.astro new file mode 100644 index 0000000..134a3bc --- /dev/null +++ b/src/components/astro/footer.astro @@ -0,0 +1,22 @@ +--- + +--- + +
+

+ © {new Date().getFullYear()} +

+ +

Designed By

+ + Guoqi Sun + + +

Powered By

+ + Astro Air + +
diff --git a/src/components/astro/header.astro b/src/components/astro/header.astro new file mode 100644 index 0000000..c336b6d --- /dev/null +++ b/src/components/astro/header.astro @@ -0,0 +1,17 @@ +--- +import { Rss } from "lucide-react" +import ThemeToggle from "~/components/astro/theme-toggle.astro" +import { site } from "~/config" +--- + +
+ +
{site.name}
+
+
+ + + + +
+
diff --git a/src/components/astro/theme-toggle.astro b/src/components/astro/theme-toggle.astro new file mode 100644 index 0000000..937c633 --- /dev/null +++ b/src/components/astro/theme-toggle.astro @@ -0,0 +1,57 @@ +--- +import { Moon, Sun } from "lucide-react" +--- + + + + diff --git a/src/components/test.tsx b/src/components/react/test.tsx similarity index 100% rename from src/components/test.tsx rename to src/components/react/test.tsx diff --git a/src/config.ts b/src/config.ts new file mode 100644 index 0000000..cfa6050 --- /dev/null +++ b/src/config.ts @@ -0,0 +1,28 @@ +export const site = { + name: "小孙同学", + favicon: "/avatar.png", + title: "小孙同学", + url: "https://blog.sunguoqi.com", + slogan: "一个浪漫的理性主义者", + description: + "🖥️ 前端小学生(React)|📸 摄影爱好者(Nikon Zfc)|🛸 旅行探索家(体验派)|🚴 骑行蹭风选手( Java 鱼雷 6-top )|🍎 科技产品发烧友(苹果&小米)

✨ 路虽远行则将至,事虽难做则必成。热爱可抵岁月漫长。山高路远,独善其身,看世界,也找自己。希望能成为一个有趣的人~", +} + +export const tabs = [ + // { + // label: "归档", + // link: "./archive", + // }, + // { + // label: "标签", + // link: "./tags", + // }, + { + label: "影集", + link: "https://camlife.cn", + }, + { + label: "关于", + link: "https://sunguoqi.com", + }, +] diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro deleted file mode 100644 index 05587c2..0000000 --- a/src/layouts/Layout.astro +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - Astro Basics - - - - - diff --git a/src/layouts/base.astro b/src/layouts/base.astro new file mode 100644 index 0000000..55427b2 --- /dev/null +++ b/src/layouts/base.astro @@ -0,0 +1,42 @@ +--- +import "~/styles/globals.css" +import { site } from "~/config" +--- + + + + + + + + + {site.title} - {site.slogan} + + + + +
+ +
+ + diff --git a/src/layouts/home.astro b/src/layouts/home.astro new file mode 100644 index 0000000..dd41fa4 --- /dev/null +++ b/src/layouts/home.astro @@ -0,0 +1,9 @@ +--- +import BaseLayout from "./base.astro" +--- + + +
+ +
+
diff --git a/src/pages/index.astro b/src/pages/index.astro index a19811d..10264b3 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,8 +1,12 @@ --- -import Layout from "../layouts/layout.astro" -import { Test } from "../components/test" +import Footer from "~/components/astro/footer.astro" +import Header from "~/components/astro/header.astro" +import { Test } from "../components/react/test" +import HomeLayout from "../layouts/home.astro" --- - + +
- +