Skip to content

Commit 0ec6db3

Browse files
fix: format
1 parent 054eb11 commit 0ec6db3

56 files changed

Lines changed: 1961 additions & 1820 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/deploy.yml

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
# Trigger the workflow every time you push to the `main` branch
55
# Using a different branch name? Replace `main` with your branch’s name
66
push:
7-
branches: [ master ]
7+
branches: [master]
88
# Allows you to run this workflow manually from the Actions tab on GitHub.
99
workflow_dispatch:
1010

@@ -17,27 +17,15 @@ permissions:
1717
jobs:
1818
build:
1919
runs-on: ubuntu-latest
20-
timeout-minutes: 3
21-
22-
strategy:
23-
matrix:
24-
node-version: [18.x]
25-
2620
steps:
2721
- name: Checkout your repository using git
2822
uses: actions/checkout@v4
29-
30-
- name: "🔧 Setup Node.js ${{ matrix.node-version }}"
31-
uses: actions/setup-node@v4
32-
with:
33-
node-version: ${{ matrix.node-version }}
34-
cache: "npm"
35-
36-
- name: "📦 Install dependencies"
37-
run: npm ci
38-
39-
- name: "🚀 Build the project"
40-
run: npm run build
23+
- name: Install, build, and upload your site
24+
uses: withastro/action@v3
25+
# with:
26+
# path: . # The root location of your Astro project inside the repository. (optional)
27+
# node-version: 20 # The specific version of Node that should be used to build your site. Defaults to 20. (optional)
28+
# package-manager: pnpm@latest # The Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. (optional)
4129

4230
deploy:
4331
needs: build
@@ -48,4 +36,4 @@ jobs:
4836
steps:
4937
- name: Deploy to GitHub Pages
5038
id: deployment
51-
uses: actions/deploy-pages@v4
39+
uses: actions/deploy-pages@v4

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# stephenfang.me
22

3-
43
## 🚀 项目介绍
54

65
使用 [Astro](https://astro.build/)[AstroPaper 📄](https://github.com/satnaing/astro-paper) 搭建的个人主页,是我个人的第一个产品。
@@ -12,23 +11,22 @@
1211
- 2022-09-20: v1.1.0 更新了阅读数量、时长等多项功能
1312
- 2020-09-07: v1.0.0 使用 Hexo 与 NexT 主题搭建
1413

15-
1614
## 💻 搭建技术
1715

18-
- [Astro](https://astro.build/)
19-
- [TypeScript](https://www.typescriptlang.org/)
20-
- [ReactJS](https://reactjs.org/)
21-
- [TailwindCSS](https://tailwindcss.com/)
16+
- [Astro](https://astro.build/)
17+
- [TypeScript](https://www.typescriptlang.org/)
18+
- [ReactJS](https://reactjs.org/)
19+
- [TailwindCSS](https://tailwindcss.com/)
2220
- [GitHub Pages](https://pages.github.com/)
2321

2422
## ✨ 内容链接
2523

2624
网站已经部署在 [stephenfang.me](https://stephenfang.me)
2725

2826
## 📜 License
27+
2928
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
3029

3130
---
3231

3332
Made with 🤍 by [StephenFang](https://github.com/iamStephenFang) in Hangzhou.
34-

src/components/Comments.tsx

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,49 @@ import { GISCUS } from "@config";
33
import { useEffect, useState } from "react";
44

55
interface CommentsProps {
6-
lightTheme?: Theme;
7-
darkTheme?: Theme;
6+
lightTheme?: Theme;
7+
darkTheme?: Theme;
88
}
99

1010
export default function Comments({
11-
lightTheme = "light",
12-
darkTheme = "dark",
11+
lightTheme = "light",
12+
darkTheme = "dark",
1313
}: CommentsProps) {
14-
const [theme, setTheme] = useState(() => {
15-
const currentTheme = localStorage.getItem("theme");
16-
const browserTheme = window.matchMedia("(prefers-color-scheme: dark)")
17-
.matches
18-
? "dark"
19-
: "light";
20-
21-
return currentTheme || browserTheme;
22-
});
23-
24-
useEffect(() => {
25-
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
26-
const handleChange = ({ matches }: MediaQueryListEvent) => {
27-
setTheme(matches ? "dark" : "light");
28-
};
29-
30-
mediaQuery.addEventListener("change", handleChange);
31-
32-
return () => mediaQuery.removeEventListener("change", handleChange);
33-
}, []);
34-
35-
useEffect(() => {
36-
const themeButton = document.querySelector("#theme-btn");
37-
const handleClick = () => {
38-
setTheme(prevTheme => (prevTheme === "dark" ? "light" : "dark"));
39-
};
40-
41-
themeButton?.addEventListener("click", handleClick);
42-
43-
return () => themeButton?.removeEventListener("click", handleClick);
44-
}, []);
45-
46-
return (
47-
<div className="mt-8">
48-
<Giscus theme={theme === "light" ? lightTheme : darkTheme} {...GISCUS} />
49-
</div>
50-
);
14+
const [theme, setTheme] = useState(() => {
15+
const currentTheme = localStorage.getItem("theme");
16+
const browserTheme = window.matchMedia("(prefers-color-scheme: dark)")
17+
.matches
18+
? "dark"
19+
: "light";
20+
21+
return currentTheme || browserTheme;
22+
});
23+
24+
useEffect(() => {
25+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
26+
const handleChange = ({ matches }: MediaQueryListEvent) => {
27+
setTheme(matches ? "dark" : "light");
28+
};
29+
30+
mediaQuery.addEventListener("change", handleChange);
31+
32+
return () => mediaQuery.removeEventListener("change", handleChange);
33+
}, []);
34+
35+
useEffect(() => {
36+
const themeButton = document.querySelector("#theme-btn");
37+
const handleClick = () => {
38+
setTheme(prevTheme => (prevTheme === "dark" ? "light" : "dark"));
39+
};
40+
41+
themeButton?.addEventListener("click", handleClick);
42+
43+
return () => themeButton?.removeEventListener("click", handleClick);
44+
}, []);
45+
46+
return (
47+
<div className="mt-8">
48+
<Giscus theme={theme === "light" ? lightTheme : darkTheme} {...GISCUS} />
49+
</div>
50+
);
5151
}

0 commit comments

Comments
 (0)