Compare commits

..

38 Commits

Author SHA1 Message Date
xy
cfeee49e68 feat: 调整git嵌入页热力图颜色 2026-11-23 17:40:40 +08:00
xy
6d3622555e fix: 修复使用了较新的api node版本不支持的问题 2026-11-23 17:37:42 +08:00
xy
41641c6f55 feat: git嵌入页新增gitea贡献统计 2026-11-23 17:19:53 +08:00
xy
6c34c5b564 feat: update gitea embed 2026-09-16 17:31:41 +08:00
xy
a4850e708f refactor: 适配tinymce编辑器获取到的数据 2026-08-29 22:53:19 +08:00
xy
0e917adc3b feat: 调整toc样式 2026-08-28 23:21:22 +08:00
xy
24fe52cfe3 style: 跳转toc样式 2026-08-28 23:15:01 +08:00
xy
3595435078 style: text-shadow替代加粗 2026-08-28 22:29:33 +08:00
xy
c7e51af0e0 style: 调整移动端样式 2026-08-28 22:20:35 +08:00
xy
26b8061389 feat: 文章添加toc 2026-08-28 22:14:41 +08:00
xy
81134bfa55 refactor: 标准化favicon 2026-08-20 23:11:11 +08:00
xy
61ec9071e5 style: 博客标题在列表中超长的问题 2026-08-19 00:20:52 +08:00
xy
1ee413d11b style: 微调color 2026-08-17 22:32:07 +08:00
xy
ebb570f0e1 style: 调整滚动条样式 2026-08-16 15:57:32 +08:00
xy
21cb0610e1 style: 调整滚动条样式 2026-08-16 15:55:07 +08:00
xy
3867a7f6cc style: 代码块主题调整 2026-08-16 15:49:40 +08:00
xy
ce2185a4c0 style: theme icon cursor 2026-08-16 15:41:52 +08:00
xy
abe1790ac1 feat: 暗色主题、主题切换按钮 2026-08-16 15:40:26 +08:00
xy
be2e6f1ae0 feat: 删除无用依赖,shiki lang使用懒加载方式加载语言 2026-08-16 13:29:58 +08:00
xy
070a63133d feat: 调整404文案 2026-08-16 11:15:04 +08:00
xy
7eb0ae75fb feat: 404界面、微调ui 2026-08-16 11:14:34 +08:00
xy
fef7f239c9 style: 微调移动端ui 2026-08-16 00:11:16 +08:00
xy
6385b36f6d style: 调整cover样式 2026-08-15 23:40:31 +08:00
xy
76247eee92 feat: 显示封面 2026-08-15 23:26:08 +08:00
xy
87f2732028 style: 调整ui 2026-08-15 22:37:05 +08:00
xy
65fc12dab6 style: 优化移动端ui 2026-08-15 22:35:50 +08:00
xy
7638a2ae0e style: 优化移动端ui 2026-08-15 22:33:09 +08:00
xy
4a224b58f4 feat: 归档页面 2026-08-15 22:23:32 +08:00
xy
390437b4bb style: 优化移动端ui 2026-08-15 21:48:37 +08:00
xy
80d461f0e2 style: 优化移动端ui 2026-08-15 21:45:31 +08:00
xy
560f6f29ea refactor: v2 2026-08-15 20:55:56 +08:00
xy
990d4b0728 style: 修复样式异常 2026-08-15 12:40:12 +08:00
xy
f7929be18d fix: sitemap路径拼写不正确的问题 2026-08-15 00:25:55 +08:00
xy
963722996e chore: 更新robot.txt 2026-08-14 23:56:44 +08:00
xy
e4c362030d feat: 动态sitemap.xml 2026-08-14 23:55:52 +08:00
xy
d7bbb7b70b style: 调整移动端视觉 2026-08-14 22:40:26 +08:00
xy
555135aedb fix: 用户手动输入query条件导致的搜索异常问题 2026-08-14 21:28:41 +08:00
xy
b3038603e8 refactor: 重写filter页面 更新为search 2026-08-14 21:08:45 +08:00
51 changed files with 1767 additions and 2930 deletions

10
.dockerignore Normal file
View File

@@ -0,0 +1,10 @@
node_modules/
.git/
.idea/
dist/
.astro/
.vscode/
.claude/
*.tar.gz
*.log
.DS_Store

View File

@@ -1,8 +1,6 @@
// @ts-check // @ts-check
import {defineConfig} from 'astro/config'; import {defineConfig} from 'astro/config';
import solidJs from '@astrojs/solid-js';
import node from '@astrojs/node'; import node from '@astrojs/node';
import sitemap from "@astrojs/sitemap";
// https://astro.build/config // https://astro.build/config
export default defineConfig({ export default defineConfig({
@@ -11,20 +9,14 @@ export default defineConfig({
server: { server: {
host: "0.0.0.0", host: "0.0.0.0",
}, },
integrations: [solidJs(), sitemap({
filter: (page) => {
return !page.includes('/embed/');
}
})],
adapter: node({ adapter: node({
mode: 'standalone' mode: 'standalone'
}), }),
vite: { vite: {
plugins: [],
server: { server: {
watch: { ...(process.argv.includes('dev')
usePolling: true, ? {watch: {usePolling: true}}
}, : {}),
}, }
}, }
}); });

View File

@@ -11,17 +11,14 @@
}, },
"dependencies": { "dependencies": {
"@astrojs/node": "11.0.2", "@astrojs/node": "11.0.2",
"@astrojs/sitemap": "^3.7.3",
"@astrojs/solid-js": "^5.1.3",
"astro": "^7.0.6", "astro": "^7.0.6",
"clipboard": "^2.0.11",
"dayjs": "^1.11.21", "dayjs": "^1.11.21",
"github-markdown-css": "^5.9.0",
"jsdom": "^29.1.1", "jsdom": "^29.1.1",
"ky": "^2.0.2", "ky": "^2.0.2",
"modern-normalize": "^3.0.1", "modern-normalize": "^3.0.1",
"photoswipe": "^5.4.4", "photoswipe": "^5.4.4",
"shiki": "^4.3.1", "shiki": "^4.3.1"
"solid-js": "^1.9.14"
}, },
"volta": { "volta": {
"node": "22.21.1" "node": "22.21.1"

1174
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,2 +1,4 @@
User-agent: * User-agent: *
Allow: / Allow: /
Sitemap: https://ua42.com/sitemap.xml

View File

@@ -1,12 +1,13 @@
FROM alpine:3.22 AS base FROM alpine:3.22 AS base
WORKDIR /app WORKDIR /app
RUN apk add --no-cache --update nodejs pnpm RUN apk add --no-cache --update nodejs
FROM base AS install FROM base AS install
RUN apk add --no-cache pnpm
ENV NODE_ENV=production ENV NODE_ENV=production
COPY package.json pnpm-lock.yaml ./ COPY package.json pnpm-lock.yaml ./
RUN pnpm install RUN pnpm install --frozen-lockfile
FROM install AS build FROM install AS build
COPY . . COPY . .

View File

@@ -1 +0,0 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1784628432297" class="icon" viewBox="0 0 1035 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9153" xmlns:xlink="http://www.w3.org/1999/xlink" width="202.1484375" height="200"><path d="M513.407379 0C230.713951 0 1.407379 229.306573 1.407379 512c0 282.693427 229.306573 512 512 512 282.693427 0 512-229.293792 512-512C1025.407379 229.306573 796.100806 0 513.407379 0z m26.17579 817.737837c-6.812352 6.799571-16.756085 10.991787-26.17579 10.991787-9.943733 0-19.37622-4.192216-26.175791-10.991787-6.799571-6.812352-10.991787-16.756085-10.991787-26.699818 0-9.943733 4.192216-19.900247 10.991787-26.699818s16.756085-10.991787 26.175791-10.991787c9.943733 0 19.363439 4.192216 26.17579 10.991787s10.991787 16.756085 10.991787 26.699818c0 9.943733-4.192216 19.887466-10.991787 26.699818z m-26.17579-87.435832c-20.424274 0-37.167578-16.743304-37.167578-37.691605 0-20.424274 16.743304-37.691605 37.167578-37.691605 20.411493 0 37.167578 16.756085 37.167577 37.691605 0 20.948301-16.756085 37.691605-37.167577 37.691605z m258.089717-237.678225c-7.847625 7.860406-17.804139 11.515814-27.747872 11.515814-9.943733 0-19.900247-3.668189-27.747871-11.515814l-163.343069-163.343069v261.23388c0 21.472328-17.804139 39.263686-39.263686 39.263686s-39.263686-17.791358-39.263687-39.263686V329.293492l-163.330287 163.343069c-15.184004 15.184004-40.31174 15.184004-55.495744 0-15.184004-15.184004-15.184004-40.31174 0-55.495744L485.646726 206.798972c15.184004-15.184004 40.31174-15.184004 55.495743 0l230.354627 230.341845c15.184004 15.171222 15.184004 39.774932 0 55.482963z m0 0" p-id="9154"></path><path d="M771.497096 492.636561c-7.847625 7.860406-17.804139 11.515814-27.747872 11.515814-9.943733 0-19.900247-3.668189-27.747871-11.515814l-163.343069-163.343069v261.23388c0 21.472328-17.804139 39.263686-39.263686 39.263686s-39.263686-17.791358-39.263687-39.263686V329.293492l-163.330287 163.343069c-15.184004 15.184004-40.31174 15.184004-55.495744 0-15.184004-15.184004-15.184004-40.31174 0-55.495744L485.659507 206.798972c15.184004-15.184004 40.31174-15.184004 55.495744 0l230.354626 230.341845c15.171222 15.184004 15.171222 39.787713-0.012781 55.495744zM513.407379 730.302005c-20.424274 0-37.167578-16.743304-37.167578-37.691605 0-20.424274 16.743304-37.691605 37.167578-37.691605 20.411493 0 37.167578 16.756085 37.167577 37.691605 0 20.948301-16.756085 37.691605-37.167577 37.691605M513.407379 828.729624c-20.424274 0-37.167578-16.743304-37.167578-37.691605 0-20.424274 16.743304-37.691605 37.167578-37.691605 20.411493 0 37.167578 16.743304 37.167577 37.691605 0 20.93552-16.756085 37.691605-37.167577 37.691605" fill="#FFFFFF" p-id="9155"></path></svg>

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

View File

@@ -1 +0,0 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1785642324396" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7302" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M695.744 981.312H419.712c-26.816 0-47.296-21.056-47.296-48.64V739.84c0-29.184 6.336-56.768 17.344-81.088-129.28-48.64-214.528-150.72-214.528-264.256 0-53.44 17.344-103.68 50.496-147.52C213.12 204.8 209.92 151.296 213.12 89.664c3.2-27.52 23.68-46.976 48.896-46.976 14.208 0 134.08 1.6 203.52 64.832a504.384 504.384 0 0 1 184.512 0C717.888 44.288 837.696 42.688 853.504 42.688a47.36 47.36 0 0 1 47.36 45.376c4.672 61.568 0 115.072-12.672 157.248 33.152 45.44 50.496 95.68 50.496 147.52 0 113.472-85.184 215.68-214.528 264.32 11.072 25.856 17.344 53.44 17.344 81.024v192.896c1.6 27.52-20.48 50.24-45.76 50.24z m-228.672-97.28h181.376V739.84c0-27.52-12.608-53.504-33.152-71.36a48.96 48.96 0 0 1-15.744-50.24c4.736-17.856 18.944-32.384 36.288-35.648 123.008-24.32 208.192-102.144 208.192-189.696 0-46.976-25.216-82.688-45.76-105.344a47.36 47.36 0 0 1-7.872-55.168c6.336-12.928 15.808-40.512 15.808-89.152-39.488 6.464-85.184 19.456-102.528 45.44a47.552 47.552 0 0 1-50.56 19.392 393.024 393.024 0 0 0-193.92 0c-18.944 4.864-37.888-3.2-50.56-19.456-17.28-25.92-63.04-38.912-102.464-45.376 1.6 48.64 9.472 76.16 15.744 89.152a53.696 53.696 0 0 1-7.872 55.168c-20.48 22.656-45.76 58.368-45.76 105.344 0 87.552 85.184 163.776 208.256 189.696 17.28 3.2 31.552 17.792 36.224 35.648a51.008 51.008 0 0 1-15.744 50.24c-20.48 17.856-33.152 43.776-33.152 71.36v144.256h3.2z" fill="#172B4D" p-id="7303"></path><path d="M403.968 788.416c-212.928 0-309.12-194.56-313.92-202.688-11.008-24.32-1.536-53.44 20.48-64.832a47.424 47.424 0 0 1 63.168 21.12c3.136 6.4 80.448 157.248 241.28 149.12a46.08 46.08 0 0 1 48.896 47.04c1.6 27.52-18.88 50.24-45.696 50.24h-14.208z" fill="#172B4D" p-id="7304"></path></svg>

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

View File

@@ -1,69 +0,0 @@
---
// 后面的 ?url 是 一个导入查询(import query),表示:不要把 SVG 当作组件或源码处理,而是返回这个资源的 URL 字符串。
import backTopIcon from "@/assets/icon/back-top.svg?url";
---
<button class="back-top" type="button" aria-label="返回顶部" hidden>
<img src={backTopIcon} alt="">
</button>
<script>
const backTop = document.querySelector<HTMLButtonElement>(".back-top")
const toggleBackTop = () => {
if (!backTop) return;
backTop.hidden = window.scrollY <= 500;
};
backTop && backTop.addEventListener("click", () => {
window.scrollTo({
top: 0,
behavior: "smooth",
});
});
window.addEventListener("scroll", toggleBackTop, {passive: true});
toggleBackTop();
</script>
<style>
.back-top {
position: fixed;
right: 150px;
bottom: 100px;
width: 44px;
height: 44px;
z-index: 999;
cursor: pointer;
padding: 0;
border: none;
background: transparent;
}
.back-top[hidden] {
display: none;
}
.back-top img {
width: 100%;
height: 100%;
display: block;
}
:global(.dark) .back-top img {
filter: invert(1);
}
.back-top:focus-visible {
outline: 2px solid currentColor;
outline-offset: 4px;
}
@media (max-width: 768px) {
.back-top {
display: none;
}
}
</style>

View File

@@ -1,46 +0,0 @@
---
import { metadata } from "../consts";
const year = new Date().getFullYear();
---
<footer>
<div class="content">
<span>© 2026 {metadata.siteTitle}</span>
<a target="_blank" href="https://beian.miit.gov.cn/#/Integrated/index">
备案号:鄂ICP备2023000060号-2
</a>
</div>
</footer>
<style>
footer {
background: #22252b;
height: 70px;
overflow: hidden;
flex-shrink: 0;
box-shadow: var(--shadow);
}
.content {
max-width: var(--layout-width);
margin: 0 auto;
color: #fff;
display: flex;
align-items: center;
height: 100%;
font-size: 14px;
justify-content: center;
gap: 12px;
}
:global(.dark) footer {
background: var(--background);
box-shadow: none;
}
:global(.dark) .content {
color: #ffffff;
}
</style>

View File

@@ -1,113 +0,0 @@
---
import {metadata} from "../consts";
import ThemeIcon from './ThemeIcon.astro'
import GitHubIcon from '@/assets/icon/github.svg?url'
---
<header>
<nav class="main-nav">
<h1>
<a href="/">{metadata.siteTitle}</a>
</h1>
<div class="main-nav-right">
<ul class="menu">
<li class="menu-item"><a href="/">首页</a></li>
<li class="menu-item"><a href="/archive">归档</a></li>
<li class="menu-item"><a target="_blank" href="https://git.ua42.com">
<img class="github-icon" src={GitHubIcon} alt="GitHub"/>
</a></li>
<!--<li class="menu-item"><a href="/">关于</a></li>-->
</ul>
<ThemeIcon/>
</div>
</nav>
</header>
<style>
header {
height: 60px;
position: sticky;
top: 0;
z-index: 99999;
box-shadow: var(--shadow);
flex-shrink: 0;
background: #fff;
}
.main-nav {
max-width: var(--layout-width);
margin: 0 auto;
height: 100%;
padding: 0 32px;
display: flex;
align-items: center;
justify-content: space-between;
}
.main-nav-right {
display: flex;
align-items: center;
gap: 12px;
}
@media (max-width: 768px) {
.main-nav {
padding: 16px;
}
}
.main-nav h1 {
user-select: none;
cursor: pointer;
font-size: 24px;
color: #000000;
}
.main-nav .menu {
list-style: none;
display: flex;
gap: 20px;
height: 100%;
align-items: center;
margin-right: 12px;
}
.menu-item {
display: flex;
align-items: center;
justify-content: center;
}
.github-icon {
width: 18px;
height: 18px;
display: block;
}
.main-nav .menu-item a {
text-decoration: none;
}
.main-nav .menu-item a:hover {
color: #64748b;
}
:global(.dark) header {
background: var(--background);
box-shadow: none;
}
:global(.dark) .main-nav h1 {
color: #ffffff;
}
:global(.dark) .main-nav .menu-item a:hover {
color: rgba(255, 255, 255, .8);
}
:global(.dark) .github-icon {
filter: invert(1);
}
</style>

View File

@@ -0,0 +1,275 @@
---
import {dayjs} from "@/lib/format.ts";
import type {HeatmapPoint} from "@/types/stats.ts";
interface Props {
points?: HeatmapPoint[]
/** IANA 时区,用于把时间戳归到某一天 */
timeZone?: string
}
const {points = [], timeZone = "Asia/Shanghai"} = Astro.props;
const CELL = 11;
const GAP = 3;
const STEP = CELL + GAP;
const TOP = 20;
const LEFT = 26;
type GridCell = {
key: string
x: number
y: number
value: number
level: number
}
const toDateText = (key: string) => key.replaceAll("-", ".");
// 按天聚合:接口按分钟返回,同一天可能有多条
const byDay = new Map<string, number>();
for (const {timestamp, contributions} of points) {
if (!Number.isFinite(timestamp) || !Number.isFinite(contributions)) continue;
const key = dayjs(timestamp * 1000).tz(timeZone).format("YYYY-MM-DD");
byDay.set(key, (byDay.get(key) ?? 0) + Math.max(0, contributions));
}
const days = [...byDay.keys()].sort();
const cells: GridCell[] = [];
const monthLabels: {x: number, label: string}[] = [];
const weekdayLabels = [
{row: 0, label: "一"},
{row: 2, label: "三"},
{row: 4, label: "五"}
];
let weeks = 0;
let total = 0;
let firstDate = "";
let lastDate = "";
const firstKey = days.at(0);
if (firstKey) {
const first = dayjs.tz(firstKey, timeZone).startOf("day");
const today = dayjs().tz(timeZone).startOf("day");
const lastData = dayjs.tz(days.at(-1) ?? firstKey, timeZone).startOf("day");
// 末尾补到今天,保证最后一列是完整的自然周
const endDay = lastData.isAfter(today) ? lastData : today;
// 列从周一开始、到周日结束
const start = first.subtract((first.day() + 6) % 7, "day");
const end = endDay.add(6 - ((endDay.day() + 6) % 7), "day");
total = [...byDay.values()].reduce((sum, value) => sum + value, 0);
firstDate = firstKey;
lastDate = endDay.format("YYYY-MM-DD");
// 用非零数据的分位数划分 4 档,避免个别高峰压扁其余格子
const nonZero = [...byDay.values()].filter((value) => value > 0).sort((a, b) => a - b);
const quantile = (p: number) => nonZero[Math.min(nonZero.length - 1, Math.floor(p * (nonZero.length - 1)))];
const t1 = Math.max(1, quantile(0.4) ?? 1);
const t2 = Math.max(t1 + 1, quantile(0.7) ?? 2);
const t3 = Math.max(t2 + 1, quantile(0.9) ?? 3);
const levelOf = (value: number) =>
value <= 0 ? 0 : value <= t1 ? 1 : value <= t2 ? 2 : value <= t3 ? 3 : 4;
let week = 0;
let weekday = 0;
for (let cursor = start; !cursor.isAfter(end); cursor = cursor.add(1, "day")) {
const key = cursor.format("YYYY-MM-DD");
const value = byDay.get(key) ?? 0;
cells.push({
key,
x: LEFT + week * STEP,
y: TOP + weekday * STEP,
value,
level: levelOf(value)
});
weekday += 1;
if (weekday === 7) {
weekday = 0;
week += 1;
}
}
weeks = week + (weekday > 0 ? 1 : 0);
// 每月第一次出现的列打上月份标签
let lastMonth = 0;
for (let i = 0; i < weeks; i++) {
const month = start.add(i, "week").month() + 1;
if (month !== lastMonth) {
monthLabels.push({x: LEFT + i * STEP, label: `${month}月`});
lastMonth = month;
}
}
}
const width = weeks > 0 ? LEFT + (weeks - 1) * STEP + CELL + 2 : 0;
const height = TOP + 7 * STEP - GAP + 2;
const levels = [0, 1, 2, 3, 4];
---
{
firstKey ? (
<section class="heatmap">
<div class="heatmap__head">
<span class="heatmap__range">{toDateText(firstDate)} - {toDateText(lastDate)}</span>
<span class="heatmap__total">共 <strong>{total}</strong> 次贡献</span>
</div>
<div class="heatmap__scroll" data-heatmap-scroll>
<svg
width={width}
height={height}
viewBox={`0 0 ${width} ${height}`}
role="img"
aria-label={`代码贡献热力图,${toDateText(firstDate)} 至 ${toDateText(lastDate)},共 ${total} 次贡献`}
>
{monthLabels.map(({x, label}) => (
<text class="heatmap__month" x={x} y={10}>{label}</text>
))}
{weekdayLabels.map(({row, label}) => (
<text class="heatmap__weekday" x={0} y={TOP + row * STEP + CELL - 2}>{label}</text>
))}
{cells.map((cell) => (
<rect
class={`heatmap__cell heatmap__cell--${cell.level}`}
x={cell.x}
y={cell.y}
width={CELL}
height={CELL}
rx={2.5}
>
<title>{cell.key} · {cell.value > 0 ? `${cell.value} 次贡献` : "无贡献"}</title>
</rect>
))}
</svg>
</div>
<div class="heatmap__foot">
<div class="heatmap__legend" aria-hidden="true">
<span>少</span>
{levels.map((level) => <span class={`heatmap__legend-cell heatmap__cell--${level}`}></span>)}
<span>多</span>
</div>
</div>
</section>
) : (
<p class="heatmap__empty">暂无贡献数据</p>
)
}
<style>
.heatmap {
padding: 14px 20px 16px;
font-size: 12px;
color: var(--text-secondary, #6b7280);
}
.heatmap__head {
display: flex;
justify-content: space-between;
align-items: baseline;
gap: 12px;
margin-bottom: 10px;
}
.heatmap__range {
font-variant-numeric: tabular-nums;
letter-spacing: 0.2px;
}
.heatmap__total strong {
font-weight: 600;
color: var(--text-color, #2b2f36);
font-variant-numeric: tabular-nums;
}
.heatmap__scroll {
overflow-x: auto;
overflow-y: hidden;
padding-bottom: 4px;
scrollbar-width: thin;
}
.heatmap__scroll svg {
display: block;
}
.heatmap__cell {
fill: var(--hm-color, #eceff4);
shape-rendering: geometricPrecision;
transition: fill 0.12s ease;
}
.heatmap__cell:hover {
stroke: var(--text-color, #2b2f36);
stroke-width: 1;
}
/* GitHub 贡献图浅色主题配色 */
.heatmap__cell--0 { --hm-color: #ebedf0; }
.heatmap__cell--1 { --hm-color: #9be9a8; }
.heatmap__cell--2 { --hm-color: #40c463; }
.heatmap__cell--3 { --hm-color: #30a14e; }
.heatmap__cell--4 { --hm-color: #216e39; }
.heatmap__month,
.heatmap__weekday {
fill: var(--text-secondary, #6b7280);
font-size: 10px;
font-family: inherit;
}
.heatmap__weekday {
text-anchor: start;
}
.heatmap__foot {
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
margin-top: 8px;
}
.heatmap__legend {
display: flex;
align-items: center;
gap: 4px;
}
.heatmap__legend-cell {
display: inline-block;
width: 11px;
height: 11px;
border-radius: 2.5px;
background: var(--hm-color, #eceff4);
}
.heatmap__empty {
margin: 0;
padding: 24px 20px;
font-size: 13px;
text-align: center;
color: var(--text-secondary, #6b7280);
}
@media (max-width: 640px) {
.heatmap {
padding: 12px 14px 14px;
}
}
</style>
<script>
// 数据从最早一天排到最新一天,窄屏下默认展示最近的部分
document.querySelectorAll<HTMLElement>("[data-heatmap-scroll]").forEach((scroller) => {
if (scroller.scrollWidth > scroller.clientWidth) {
scroller.scrollLeft = scroller.scrollWidth;
}
});
</script>

View File

@@ -0,0 +1,40 @@
---
import PostList from "@/components/Post/List.astro";
import Pagination from "@/components/Post/Pagination.astro";
import type {Post} from "@/types";
interface Props {
posts: Post[]
page: number
totalPage: number
}
const {posts, page, totalPage} = Astro.props
---
<main>
<div class="intro">
<p>did you stand too close to the fire?<br>
like a liar looking for forgiveness from a stone.</p>
</div>
<PostList posts={posts}/>
<Pagination page={page} totalPage={totalPage}/>
</main>
<style>
.intro {
border-bottom: var(--border-secondary);
line-height: 2;
font-size: 15px;
color: var(--text-secondary);
padding-bottom: 32px;
margin-bottom: 12px;
}
@media (max-width: 640px) {
.intro{
padding-bottom: 24px;
}
}
</style>

View File

@@ -1,151 +0,0 @@
---
import Folder from "@/assets/icon/folder.png?url";
import TagIcon from "@/assets/icon/tag.png?url";
import type { CategoriesStats,Tag } from "@/types";
import { createHttp } from "@/lib/request";
const http = createHttp(Astro.request.headers);
const { data: categories } =
await http.get<ApiResponse<CategoriesStats[]>>("categories/stats");
const { data: tags } =
await http.get<ApiResponse<Tag[]>>("posts/tags");
---
<aside class="sidebar">
<div class="widget">
<h3 class="widget-title">
<img src={Folder} alt="Folder" />
文章分类
</h3>
<ul class="category-list">
{
categories.map((category) => (
<li>
<a
href={`/filter?type=category&code=${encodeURIComponent(category.code)}`}
title={`${category.name} · ${category.post_count} 篇`}
>
{category.name}
</a>
<span class="count">{category.post_count}</span>
</li>
))
}
</ul>
</div>
<div class="widget">
<h3 class="widget-title">
<img src={TagIcon} alt="Tag" />
标签云
</h3>
<div class="tag-cloud">
{
tags.map((tag) => (
<a
class="tag"
href={`/filter?type=tag&code=${encodeURIComponent(tag.code)}`}
>
{tag.name}
</a>
))
}
</div>
</div>
</aside>
<style>
.sidebar {
width: 300px;
height: 100%;
display: flex;
flex-direction: column;
gap: 20px;
}
.widget {
background: var(--card-bg);
border-radius: 12px;
box-shadow: var(--shadow);
padding: 22px;
}
.widget-title {
font-size: 16px;
font-weight: 700;
margin-bottom: 16px;
padding-bottom: 10px;
border-bottom: 1px solid var(--border);
display: flex;
gap: 8px;
}
.widget-title img {
width: 18px;
height: 18px;
}
/* 分类 & 标签云 */
.category-list {
list-style: none;
}
.category-list li {
display: flex;
justify-content: space-between;
padding: 8px 4px;
font-size: 14px;
border-bottom: 1px dashed var(--border);
}
.category-list li:last-child {
border-bottom: none;
}
.category-list a:hover {
color: #4f6df5;
}
.category-list .count {
color: var(--text-secondary);
font-size: 13px;
}
.tag-cloud {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.tags {
display: flex;
gap: 8px;
flex-wrap: wrap;
}
.tag {
font-size: 12px;
color: var(--tag-text);
background: var(--tag-bg);
padding: 3px 10px;
border-radius: 999px;
transition: background 0.2s;
}
.tag:hover {
background: var(--tag-hover-bg);
}
@media (max-width: 860px) {
.sidebar {
width: 100%;
}
}
@media (max-width: 860px) {
.sidebar {
gap: 16px;
}
}
</style>

View File

@@ -1,34 +0,0 @@
---
import type { Post } from "@/types/post";
import IndexSidebar from "@/components/IndexSidebar.astro";
import PostList from "@/components/PostList.astro";
interface Props {
posts: Post[];
page: number;
totalPage: number;
}
const { posts, page, totalPage } = Astro.props;
---
<div class="page-content">
<div class="container">
<PostList posts={posts} page={page} totalPage={totalPage} />
<IndexSidebar />
</div>
</div>
<style>
.container {
width: 100%;
display: flex;
gap: 28px;
}
@media (max-width: 860px) {
.container {
flex-direction: column;
}
}
</style>

View File

@@ -52,7 +52,6 @@ const {
.placeholder { .placeholder {
position: absolute; position: absolute;
inset: 0; inset: 0;
background: #f3f4f6;
background-image: linear-gradient( background-image: linear-gradient(
90deg, 90deg,
#f3f4f6 0%, #f3f4f6 0%,

View File

@@ -0,0 +1,83 @@
---
import type {Post} from "@/types";
import {formatDatetime} from '@/lib/format.ts'
interface Props {
posts: Post[]
}
const {posts} = Astro.props
---
<div class="posts">
{posts.map(item => (
<div class="post">
<span class="d">{formatDatetime(item.published_at, 'YY.MM.DD')}</span>
<h2><a href=`/post/${item.slug}`>{item.title}</a></h2>
<span class="arrow">→</span>
</div>
))}
</div>
<style>
.posts {
}
.post {
display: flex;
align-items: baseline;
gap: 20px;
padding: 26px 0;
border-bottom: var(--border-secondary);
}
.post .d {
font-size: 14px;
color: var(--text-meta);
min-width: 80px;
letter-spacing: 1px;
}
.post h2 {
font-size: 16px;
font-weight: normal;
flex: 1;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.post h2 a {
color: var(--text-primary);
text-decoration: none;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.post h2 a:hover {
color: var(--text-title-hover);
text-decoration: underline;
text-underline-offset: 6px;
}
.post .arrow {
color: #d0d0d0;
font-size: 14px;
transition: transform 0.2s, color 0.2s;
}
.post:hover .arrow {
color: #334155;
}
@media (max-width: 640px) {
.post .d {
min-width: 64px;
}
.post h2 {
font-size: 15px;
}
}
</style>

View File

@@ -0,0 +1,49 @@
---
interface Props {
page: number
totalPage: number
}
const {page, totalPage} = Astro.props
---
<!--分页器-->
{totalPage > 1 &&
<nav class="pagination" aria-label="分页">
{Array.from({length: totalPage}).map((_, index) => {
if (page === index + 1) {
return <span class="link current">{index + 1}</span>
}
return <a class="link" href={`/page/${index + 1}`}>{index + 1}</a>
})}
{page < totalPage ? <a href={`/page/${page + 1}`} class="link">下一页</a> :
<span class="link disabled">下一页</span>}
</nav>}
<style>
/* ========== 分页 ========== */
.pagination {
width: 100%;
text-align: right;
white-space: nowrap;
margin-top: 32px;
font-size: 13px;
}
.link {
display: inline-block;
margin: 0 12px;
line-height: 1;
color: var(--text-secondary);
}
.current{
color: var(--text-primary);
font-weight: bold;
}
.link.disabled {
color: var(--text-disabled);
cursor: not-allowed;
}
</style>

View File

@@ -0,0 +1,176 @@
---
import { type TocNode } from "@/lib/processHtml";
interface Props {
toc: TocNode[];
}
const { toc } = Astro.props;
const lowLevel = Math.min(...toc.map((v) => v.level));
---
<div class="toc-mount">
<div class="toc">
{
toc.map((item) => {
return (
<a
href={`#${item.id}`}
class="toc-item"
style={{ paddingLeft: `${(item.level - lowLevel) * 8}px` }}
>
{item.text}
</a>
);
})
}
</div>
</div>
<style>
.toc-mount {
position: absolute;
top: 0;
bottom: -64px;
right: -320px;
width: 280px;
padding: 0px 0;
}
.toc {
position: sticky;
top: 60px;
height: calc(100vh - 120px);
width: 100%;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 12px;
border-left: var(--border-secondary);
padding-left: 24px;
}
.toc-item {
color: var(--text-primary);
font-size: 14px;
line-height: 20px;
}
.toc-item:hover {
color: var(--text-title-hover);
text-shadow:
0.3px 0 0 currentColor,
-0.3px 0 0 currentColor;
}
.toc-item.is-active {
position: relative;
color: var(--text-title-hover);
text-shadow:
0.3px 0 0 currentColor,
-0.3px 0 0 currentColor;
}
.toc-item.is-active::before {
content: "";
position: absolute;
left: -25px;
top: 50%;
transform: translateY(-50%);
width: 2px;
height: 18px;
border-radius: 2px;
background: currentColor;
}
@media (max-width: 1250px) {
.toc-mount {
display: none;
}
}
</style>
<script>
const links = Array.from(
document.querySelectorAll<HTMLAnchorElement>(".toc-item"),
);
const headings = links
.map((link) => {
const id = link.getAttribute("href")?.slice(1);
return id ? { link, heading: document.getElementById(id) } : null;
})
.filter((x): x is { link: HTMLAnchorElement; heading: HTMLElement } =>
Boolean(x?.heading),
);
if (headings.length > 0) {
const toc = document.querySelector<HTMLElement>(".toc");
const ACTIVE_OFFSET = 100;
let currentId: string | null = null;
let raf = 0;
const scrollActiveIntoView = (link: HTMLAnchorElement) => {
if (!toc) return;
const containerTop = toc.getBoundingClientRect().top;
const linkTop =
link.getBoundingClientRect().top - containerTop + toc.scrollTop;
const linkBottom =
link.getBoundingClientRect().bottom - containerTop + toc.scrollTop;
if (linkTop < toc.scrollTop) {
toc.scrollTop = linkTop;
} else if (linkBottom > toc.scrollTop + toc.clientHeight) {
toc.scrollTop = linkBottom - toc.clientHeight;
}
};
const setActive = (id: string | null) => {
if (id === currentId) return;
currentId = id;
for (const { link, heading } of headings) {
const active = heading.id === id;
link.classList.toggle("is-active", active);
if (active) {
link.setAttribute("aria-current", "location");
scrollActiveIntoView(link);
} else {
link.removeAttribute("aria-current");
}
}
};
const update = () => {
raf = 0;
const doc = document.documentElement;
const atBottom =
window.scrollY + window.innerHeight >= doc.scrollHeight - 4;
let activeId: string | null = null;
if (atBottom) {
activeId = headings[headings.length - 1].heading.id;
} else {
for (const { heading } of headings) {
if (heading.getBoundingClientRect().top <= ACTIVE_OFFSET) {
activeId = heading.id;
} else {
break;
}
}
}
setActive(activeId);
};
const onScroll = () => {
if (raf) return;
raf = requestAnimationFrame(update);
};
window.addEventListener("scroll", onScroll, { passive: true });
window.addEventListener("resize", onScroll, { passive: true });
update();
}
</script>

View File

@@ -1,267 +0,0 @@
---
import Eye from "@/assets/icon/eye.png?url";
import Folder from "@/assets/icon/folder.png?url";
import Calendar from "@/assets/icon/calendar.png?url";
import type {Post} from "@/types/post";
import {formatDatetime} from "@/lib/format.ts";
import LazyImage from "@/components/LazyImage.astro";
interface Props {
posts: Post[]
page: number
totalPage: number
}
const {posts, page, totalPage} = Astro.props
posts.map((post) => {
post.published_at = formatDatetime(post.published_at, 'YYYY-MM-DD')
})
---
<section class="section">
<div class="post-list">
{posts.map(post => (
<a href={`/post/${post.slug}`}>
<article class="post-card">
<div class="post-cover">
<LazyImage src={post.cover} alt={post.title} />
</div>
<div class="post-body">
<div class="post-meta">
<span>
<img src={Calendar} alt="Calendar"/>
{post.published_at}
</span>
<span>
<img src={Folder} alt="Folder"/>
{post.category_name}
</span>
<span>
<img src={Eye} alt="Eye"/>
{post.view}
</span>
</div>
<h3 class="post-title">
{post.title}
</h3>
<div class="post-summary">
{post.summary}
</div>
<div class="tags">
{post.tags.map(tag => <div class="tag">{tag.name}</div>)}
</div>
</div>
</article>
</a>
))}
</div>
<!--分页器-->
{totalPage > 1 &&
<nav class="pagination" aria-label="分页">
{page > 1 ? <a href={`/page/${page - 1}`} class="link">« 上一页</a> : <span class="link disabled">« 上一页</span>}
{Array.from({length: totalPage}).map((_, index) => {
if (page === index + 1) {
return <span class="link current">{index + 1}</span>
}
return <a class="link" href={`/page/${index + 1}`}>{index + 1}</a>
})}
{page < totalPage ? <a href={`/page/${page + 1}`} class="link">下一页 »</a> :
<span class="link disabled">下一页 »</span>}
</nav>}
</section>
<style>
.section {
flex: 1;
height: 100%;
}
.post-list {
display: flex;
flex-direction: column;
gap: 20px;
}
.post-card {
background: var(--card-bg);
border-radius: 12px;
box-shadow: var(--shadow);
padding: 16px;
transition: transform 0.2s, box-shadow 0.2s;
display: flex;
gap: 22px;
}
@media (hover: hover) and (pointer: fine) {
.post-card:hover {
transform: translateY(-3px);
box-shadow: var(--shadow-hover);
}
}
.post-cover {
flex-shrink: 0;
width: 160px;
height: 100px;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
font-size: 40px;
color: #fff;
overflow: hidden;
}
.post-body {
flex: 1;
min-width: 0;
}
.post-meta {
font-size: 12px;
color: var(--text-secondary);
margin-bottom: 6px;
display: flex;
gap: 14px;
flex-wrap: wrap;
}
.post-meta span {
display: flex;
align-items: center;
gap: 4px;
}
.post-meta span img {
width: 14px;
height: 14px;
display: block;
}
.post-title {
font-size: 20px;
font-weight: 700;
margin-bottom: 8px;
line-height: 1.4;
}
.post-summary {
font-size: 14px;
color: var(--text-secondary);
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
margin-bottom: 12px;
}
.tags {
display: flex;
gap: 8px;
flex-wrap: wrap;
}
.tag {
font-size: 12px;
color: var(--tag-text);
background: var(--tag-bg);
padding: 3px 10px;
border-radius: 999px;
transition: background 0.2s;
}
.tag:hover {
background: var(--tag-hover-bg);
}
/* ========== 分页 ========== */
.pagination {
display: flex;
justify-content: center;
gap: 8px;
margin-top: 32px;
}
.link {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 38px;
height: 38px;
padding: 0 12px;
border-radius: 8px;
background: var(--card-bg);
border: 1px solid var(--border);
font-size: 14px;
color: var(--text-secondary);
transition: all 0.2s;
}
.link:hover,
.link.current {
background: var(--primary);
border-color:var(--primary);
color: #fff;
}
.link.disabled {
color: var(--text-secondary);
background: var(--card-bg);
border-color: var(--border);
cursor: not-allowed;
}
@media (max-width: 860px) {
.post-list{
gap: 16px;
}
.post-card {
padding: 16px;
gap: 12px;
}
.post-cover {
width: 128px;
height: 80px;
}
.post-title {
font-size: 18px;
}
.post-meta{
gap: 8px;
font-size: 12px;
}
}
@media (max-width: 560px) {
.post-card {
padding: 12px;
}
.post-title {
font-size: 16px;
margin-bottom: 4px;
}
.post-meta{
gap: 6px;
font-size: 12px;
}
.post-cover {
width: 100px;
height: 62px;
}
.post-summary{
font-size: 12px;
margin-bottom: 6px;
}
}
</style>

View File

@@ -1,7 +1,7 @@
--- ---
--- ---
<div class="theme-toggle" id="themeToggle" aria-label="Toggle theme"> <div class="theme-toggle" id="themeToggle" aria-label="Toggle theme">
<svg aria-hidden="true" width="20px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> <svg aria-hidden="true" width="16px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path class="sun" fill-rule="evenodd" <path class="sun" fill-rule="evenodd"
d="M12 17.5a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11zm0 1.5a7 7 0 1 0 0-14 7 7 0 0 0 0 14zm12-7a.8.8 0 0 1-.8.8h-2.4a.8.8 0 0 1 0-1.6h2.4a.8.8 0 0 1 .8.8zM4 12a.8.8 0 0 1-.8.8H.8a.8.8 0 0 1 0-1.6h2.5a.8.8 0 0 1 .8.8zm16.5-8.5a.8.8 0 0 1 0 1l-1.8 1.8a.8.8 0 0 1-1-1l1.7-1.8a.8.8 0 0 1 1 0zM6.3 17.7a.8.8 0 0 1 0 1l-1.7 1.8a.8.8 0 1 1-1-1l1.7-1.8a.8.8 0 0 1 1 0zM12 0a.8.8 0 0 1 .8.8v2.5a.8.8 0 0 1-1.6 0V.8A.8.8 0 0 1 12 0zm0 20a.8.8 0 0 1 .8.8v2.4a.8.8 0 0 1-1.6 0v-2.4a.8.8 0 0 1 .8-.8zM3.5 3.5a.8.8 0 0 1 1 0l1.8 1.8a.8.8 0 1 1-1 1L3.5 4.6a.8.8 0 0 1 0-1zm14.2 14.2a.8.8 0 0 1 1 0l1.8 1.7a.8.8 0 0 1-1 1l-1.8-1.7a.8.8 0 0 1 0-1z"/> d="M12 17.5a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11zm0 1.5a7 7 0 1 0 0-14 7 7 0 0 0 0 14zm12-7a.8.8 0 0 1-.8.8h-2.4a.8.8 0 0 1 0-1.6h2.4a.8.8 0 0 1 .8.8zM4 12a.8.8 0 0 1-.8.8H.8a.8.8 0 0 1 0-1.6h2.5a.8.8 0 0 1 .8.8zm16.5-8.5a.8.8 0 0 1 0 1l-1.8 1.8a.8.8 0 0 1-1-1l1.7-1.8a.8.8 0 0 1 1 0zM6.3 17.7a.8.8 0 0 1 0 1l-1.7 1.8a.8.8 0 1 1-1-1l1.7-1.8a.8.8 0 0 1 1 0zM12 0a.8.8 0 0 1 .8.8v2.5a.8.8 0 0 1-1.6 0V.8A.8.8 0 0 1 12 0zm0 20a.8.8 0 0 1 .8.8v2.4a.8.8 0 0 1-1.6 0v-2.4a.8.8 0 0 1 .8-.8zM3.5 3.5a.8.8 0 0 1 1 0l1.8 1.8a.8.8 0 1 1-1 1L3.5 4.6a.8.8 0 0 1 0-1zm14.2 14.2a.8.8 0 0 1 1 0l1.8 1.7a.8.8 0 0 1-1 1l-1.8-1.7a.8.8 0 0 1 0-1z"/>
<path class="moon" fill-rule="evenodd" <path class="moon" fill-rule="evenodd"
@@ -19,6 +19,7 @@
.theme-toggle { .theme-toggle {
display: flex; display: flex;
align-items: center; align-items: center;
cursor: pointer;
} }
.sun { .sun {

View File

@@ -1,5 +1,7 @@
export const metadata = { export const siteConfig = {
site: "https://ua42.com",
siteTitle: "Uroboros", siteTitle: "Uroboros",
postPageSize: 7,
postPageSize: 6 description: "love yourself.",
git: "https://git.ua42.com"
} }

View File

@@ -0,0 +1,33 @@
---
import "@/styles/global.css";
import { siteConfig } from "@/consts.ts";
const { siteTitle } = siteConfig;
interface Props {
title?: string;
description?: string;
}
const { title, description } = Astro.props;
const pageTitle = title ? `${title} - ${siteTitle}` : siteTitle;
---
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
/>
<link rel="icon" href="/favicon.ico" />
<meta name="generator" content={Astro.generator} />
<meta name="description" content={description} />
<meta name="theme-color" content="#ffffff" />
<title>{pageTitle}</title>
</head>
<body>
<slot />
</body>
</html>

View File

@@ -1,42 +1,44 @@
--- ---
import "@/styles/global.css"; import BaseLayout from "./BaseLayout.astro";
import PageHeader from "./PageHeader.astro";
import BaseHeader from "@/components/BaseHeader.astro"; import PageFooter from "./PageFooter.astro";
import BaseFooter from "@/components/BaseFooter.astro";
import BackTop from "@/components/BackTop.astro";
import { metadata } from "@/consts.ts";
const { siteTitle } = metadata;
interface Props {
title?: string;
description?: string;
}
const { title, description } = Astro.props;
const pageTitle = title ? `${title} - ${siteTitle}` : siteTitle;
--- ---
<!doctype html> <BaseLayout {...Astro.props}>
<html lang="zh-CN"> <div class="container">
<head> <PageHeader />
<meta charset="UTF-8" /> <main>
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
/>
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<meta name="generator" content={Astro.generator} />
<meta name="description" content={description} />
<meta name="theme-color" content="#ffffff" />
<title>{pageTitle}</title>
</head>
<body>
<BaseHeader />
<main class="main">
<slot /> <slot />
</main> </main>
<BaseFooter /> <PageFooter />
<BackTop /> </div>
</body> </BaseLayout>
</html>
<style>
.container {
width: 100%;
max-width: var(--layout-width);
min-height: 100%;
margin: 0 auto;
padding: 24px;
display: flex;
flex-direction: column;
}
main {
flex: 1;
padding: 24px 0;
display: flex;
flex-direction: column;
}
@media (max-width: 640px) {
.container {
padding: 16px;
}
main{
padding-bottom: 0;
}
}
</style>

View File

@@ -0,0 +1,23 @@
<footer>
<div>© 2026 Uroboros</div>
<a href="https://beian.miit.gov.cn" target="_blank"
>备案号:鄂ICP备2023000060号-2</a
>
</footer>
<style>
footer {
flex-shrink: 0;
min-height: 0;
height: 64px;
display: flex;
justify-content: center;
align-items: center;
font-size: 13px;
gap: 12px;
color: var(--text-secondary);
max-width: var(--layout-width);
margin: 0 auto;
width: 100%;
}
</style>

View File

@@ -0,0 +1,58 @@
---
import { siteConfig } from "@/consts.ts";
import ThemeIcon from "@/components/ThemeIcon.astro";
const { siteTitle, git } = siteConfig;
---
<header>
<a href="/"><h1>{siteTitle}</h1></a>
<nav>
<a href="/archive">归档</a>
<a target="_blank" href={git}>git</a>
<ThemeIcon />
</nav>
</header>
<style>
header {
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: var(--border-primary);
width: 100%;
max-width: var(--layout-width);
padding: 32px 0 24px;
margin: 0 auto 24px;
}
nav {
display: flex;
align-items: center;
gap: 16px;
font-size: 14px;
color: var(--text-secondary);
}
nav a:hover {
color: var(--text-primary);
}
h1 {
font-size: 24px;
font-weight: 600;
}
@media (max-width: 640px) {
header {
padding-top: 12px;
margin-bottom: 0;
}
h1 {
font-size: 20px;
font-weight: normal;
}
}
</style>

View File

@@ -5,6 +5,8 @@ import timezone from 'dayjs/plugin/timezone';
dayjs.extend(utc); dayjs.extend(utc);
dayjs.extend(timezone); dayjs.extend(timezone);
export { dayjs };
export const formatDatetime = (date: string,format = 'YYYY-MM-DD HH:mm') => { export const formatDatetime = (date: string,format = 'YYYY-MM-DD HH:mm') => {
return dayjs(date).tz('Asia/Shanghai').format(format); return dayjs(date).tz('Asia/Shanghai').format(format);
}; };

View File

@@ -1,85 +0,0 @@
import {JSDOM} from 'jsdom'
import {createHighlighter} from 'shiki'
const highlighter = await createHighlighter({
themes: ['github-dark-dimmed'],
langs: [
"bash",
"json",
"yaml",
"xml",
"html",
"css",
"scss",
"javascript",
"typescript",
"jsx",
"tsx",
"vue",
"markdown",
"sql",
"graphql",
"python",
"java",
"go",
"rust",
"c",
"cpp",
"csharp",
"php",
"ruby",
"kotlin",
"swift",
"dockerfile",
"nginx"
]
})
const resolveLang = (lang) => {
const supported = highlighter.getLoadedLanguages?.() || []
if (!lang) return 'text'
if (supported.includes(lang)) return lang
return 'text'
}
export const highlightHtmlWithJsdom = async (rawHtml) => {
const dom = new JSDOM(rawHtml)
const document = dom.window.document
const codeElements = document.querySelectorAll('pre code')
for (const codeEl of codeElements) {
const preEl = codeEl.parentElement
if (!preEl || preEl.tagName !== 'PRE') continue
const codeContent = codeEl.textContent?.trim() || ''
// 提取语言
let lang = 'text'
for (const cls of codeEl.classList) {
if (cls.startsWith('language-')) {
lang = cls.slice('language-'.length)
break
}
}
lang = resolveLang(lang)
// 生成高亮 HTML
const highlighted = highlighter.codeToHtml(codeContent, {
lang,
theme: 'github-dark-dimmed',
})
// 替换 DOM
const wrapper = document.createElement('div')
wrapper.innerHTML = highlighted.trim()
const newNode = wrapper.firstChild
if (newNode && preEl.parentNode) {
preEl.parentNode.replaceChild(newNode, preEl)
}
}
return dom.serialize()
}

206
src/lib/processHtml.ts Normal file
View File

@@ -0,0 +1,206 @@
import {JSDOM} from "jsdom";
import {createHighlighter} from "shiki";
const DEFAULT_THEME = "github-dark-dimmed";
type SupportedLang = (typeof SUPPORTED_LANGS)[number];
const highlighter = await createHighlighter({
themes: [DEFAULT_THEME],
langs: [],
});
const SUPPORTED_LANGS = [
"bash",
"json",
"yaml",
"xml",
"html",
"css",
"scss",
"javascript",
"typescript",
"jsx",
"tsx",
"vue",
"markdown",
"sql",
"python",
"go",
"dockerfile",
"nginx",
] as const;
const loadedLangs = new Set<string>(["text"]);
const supportedSet = new Set<string>(SUPPORTED_LANGS);
const LANG_MAP: Record<string, string> = {
markup: "html",
html: "html",
};
const normalizeLang = (lang: string): string => {
return LANG_MAP[lang] || lang;
};
const ensureLangLoaded = async (lang: string): Promise<string> => {
if (lang === "text" || loadedLangs.has(lang)) return lang;
if (!supportedSet.has(lang)) return "text";
try {
await highlighter.loadLanguage(lang as SupportedLang);
loadedLangs.add(lang);
return lang;
} catch {
return "text";
}
};
async function processCodeBlocks(document: Document) {
const codeBlocks = document.querySelectorAll("pre code");
for (const codeBlock of codeBlocks) {
const preEl = codeBlock.parentElement;
if (!preEl || preEl.tagName !== "PRE") continue;
const codeContent = codeBlock.textContent || "";
let rawLang = "text";
for (const cls of preEl.classList) {
if (cls.startsWith("language-")) {
rawLang = cls.slice("language-".length);
break;
}
}
const lang = normalizeLang(rawLang);
const loadedLang = await ensureLangLoaded(lang);
const highlighted = highlighter.codeToHtml(codeContent, {
lang: loadedLang,
theme: DEFAULT_THEME,
});
// 替换 DOM
const wrapper = document.createElement("div");
wrapper.innerHTML = highlighted.trim();
const newNode = wrapper.firstElementChild;
if (newNode && preEl.parentNode) {
const container = document.createElement("div");
container.className = "code-block";
const header = document.createElement("div");
header.className = "code-header";
const headerLeft = document.createElement("div");
headerLeft.className = "code-header-left";
const headerRight = document.createElement("div");
headerRight.className = "code-header-right";
// 装饰点
const actions = document.createElement("div");
actions.className = "code-actions";
const close = document.createElement("span");
close.className = "dot close";
const minimize = document.createElement("span");
minimize.className = "dot minimize";
const maximize = document.createElement("span");
maximize.className = "dot maximize";
actions.append(close, minimize, maximize);
// 显示语言
const langDisplay = document.createElement("div");
langDisplay.className = "code-language";
langDisplay.textContent = lang ? lang : "text";
const copyBtn = document.createElement("div");
copyBtn.className = "code-copy-btn";
copyBtn.textContent = "复制代码";
headerLeft.append(actions, langDisplay);
headerRight.append(copyBtn);
header.append(headerLeft, headerRight);
container.append(header, newNode);
preEl.parentNode.replaceChild(container, preEl);
}
}
}
type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
export interface TocNode {
level: HeadingLevel;
id: string;
text: string;
element: HTMLHeadingElement;
}
function createHeadingId(text: string, doc: Document): string {
const base = text.trim() || "heading";
let id = base;
let index = 1;
while (doc.getElementById(id)) {
id = `${base}-${index++}`;
}
return id;
}
function getToc(document: Document): TocNode[] {
const headings = Array.from(
document.querySelectorAll<HTMLHeadingElement>("h1, h2, h3, h4, h5, h6"),
);
const result: TocNode[] = [];
for (const element of headings) {
const level = Number(element.tagName.slice(1)) as HeadingLevel;
const id =
element.id || createHeadingId(element.textContent ?? "", document);
element.id = id;
const node: TocNode = {
level,
id,
text: element.textContent?.trim() ?? "",
element,
};
result.push(node);
}
return result;
}
type ParseResult = {
html: string;
toc: TocNode[];
};
export const processHtmlWithJsdom = async (
rawHtml: string,
): Promise<ParseResult> => {
const dom = new JSDOM(rawHtml);
const document = dom.window.document;
await processCodeBlocks(document);
const toc = getToc(document)
return {
html: document.body.innerHTML,
toc,
};
};

View File

@@ -2,28 +2,17 @@
import Layout from "@/layouts/Layout.astro"; import Layout from "@/layouts/Layout.astro";
--- ---
<Layout title="404"> <Layout title="404" description="这里什么也没有">
<div class="not-found"> <div class="not-found">
<h1>404 Not Found</h1> <h1>404 NOT FOUND</h1>
<a class="back-home" href="/">返回首页</a>
</div> </div>
</Layout> </Layout>
<style> <style>
.not-found{ .not-found{
flex: 1; height: 100%;
width: 100%;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
flex-direction: column;
gap: 20px;
}
.back-home {
background: black;
color: white;
padding: 10px 20px;
border-radius: 12px;
} }
</style> </style>

View File

@@ -8,14 +8,14 @@ const http = createHttp(Astro.request.headers);
const {data} = await http.get<ApiResponse<Archive>>("posts/archives"); const {data} = await http.get<ApiResponse<Archive>>("posts/archives");
--- ---
<Layout title="归档">
<div class="page-content"> <Layout title="归档" description="">
<div class="archive"> <div class="archive">
{ {
data.map((year) => ( data.map((year) => (
<div class="archive-year"> <div class="archive-year">
<h2 class="year-title"> <h2 class="year-title">
<span class="year-badge">{year.year}</span> <span class="year-badge">{year.year}年</span>
<span class="year-count">共 {year.total} 篇</span> <span class="year-count">共 {year.total} 篇</span>
</h2> </h2>
<div> <div>
@@ -28,7 +28,7 @@ const {data} = await http.get<ApiResponse<Archive>>("posts/archives");
<span class="post-date"> <span class="post-date">
{post.published_at_display} {post.published_at_display}
</span> </span>
<a href={`/post/${post.slug}`}>{post.title}</a> <a class="post-title" href={`/post/${post.slug}`}>{post.title}</a>
<span class="post-cat">{post.category_name}</span> <span class="post-cat">{post.category_name}</span>
</li> </li>
))} ))}
@@ -40,158 +40,96 @@ const {data} = await http.get<ApiResponse<Archive>>("posts/archives");
)) ))
} }
</div> </div>
</div>
</Layout> </Layout>
<style> <style>
:root {
--border: #e5e7eb;
--radius: 12px;
--shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.archive { .archive {
max-width: 860px;
margin: 0 auto;
} }
.archive-year { .archive-year {
margin-bottom: 40px;
} }
.year-title { .year-title {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 14px; gap: 12px;
font-size: 24px; color: var(--text-primary);
font-weight: 700; font-size: 28px;
margin-bottom: 18px;
}
.year-title .year-badge {
background: linear-gradient(135deg, #4f6df5, #7b5cf0);
color: #fff;
padding: 8px 16px;
border-radius: 999px;
font-size: 20px;
}
.year-title .year-count {
font-size: 13px;
color: var(--text-secondary);
font-weight: 400;
}
.year-title::after {
content: "";
flex: 1;
height: 1px;
background: var(--border);
}
/* 月份分组 */
.month-group {
position: relative;
padding-left: 28px;
margin-bottom: 24px; margin-bottom: 24px;
} }
/* 时间轴竖线 */ .year-badge {
.month-group::before {
content: ""; }
position: absolute;
left: 7px; .year-count {
top: 8px; font-size: 14px;
bottom: 0; font-weight: normal;
width: 2px; }
background: var(--border);
.month-group {
padding: 12px 0;
} }
.month-title { .month-title {
position: relative; color: var(--text-primary);
font-size: 17px; font-weight: normal;
font-weight: 700;
color: var(--primary);
margin-bottom: 10px;
}
:global(.dark) .month-title{
color: inherit;
}
/* 月份节点圆点 */
.month-title::before {
content: "";
position: absolute;
left: -26px;
top: 8px;
width: 10px;
height: 10px;
border-radius: 50%;
background: var(--primary);
box-shadow: 0 0 0 3px var(--tag-bg);
} }
.post-list { .post-list {
list-style: none; padding: 12px 0;
background: var(--card-bg); display: flex;
border-radius: var(--radius); flex-direction: column;
box-shadow: var(--shadow);
overflow: hidden;
} }
.post-item { .post-item {
display: flex; display: flex;
align-items: baseline; gap: 24px;
gap: 14px; font-size: 14px;
padding: 18px 20px; border-bottom: var(--border-secondary);
border-bottom: 1px solid var(--border); padding: 18px 0;
transition: background 0.2s; align-items: center;
} }
.post-item:last-child { .post-item:last-child {
border-bottom: none; border-bottom: none;
} }
.post-item:hover {
background: #f9faff;
}
:global(.dark) .post-item:hover {
background: none;
}
.post-date { .post-date {
flex-shrink: 0; color: var(--text-meta);
font-size: 13px;
color: var(--text-secondary);
font-variant-numeric: tabular-nums;
width: 52px;
} }
.post-item a { .post-title {
flex: 1; flex: 1;
min-width: 0;
font-size: 15px;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis;
color: var(--text-primary);
font-size: 16px;
text-underline-offset: 4px;
line-height: 24px;
} }
.post-item a:hover { .post-title:hover{
color: var(--primary); color: var(--text-title-hover);
} text-decoration: underline;
:global(.dark) .post-item a:hover {
color: inherit;
} }
.post-cat { .post-cat {
flex-shrink: 0; color: var(--text-meta);
font-size: 12px; font-size: 14px;
color: var(--primary);
background: var(--tag-bg);
padding: 2px 10px;
border-radius: 999px;
} }
@media (max-width: 640px) {
.year-title{
font-size: 24px;
}
.post-title{
font-size: 15px;
}
}
</style> </style>

View File

@@ -1,6 +1,57 @@
--- ---
import ContributionHeatmap from "@/components/ContributionHeatmap.astro";
import { createHttp } from "@/lib/request.ts";
import type { HeatmapPoint } from "@/types/stats.ts";
const noindex = true; const noindex = true;
import {metadata} from '@/consts.ts'
// 与接口 https://admin.ua42.com/api/stats/gitea/x/heatmap 对应
const GITEA_USER = "x";
let heatmap: HeatmapPoint[] = [];
try {
const { data } = await createHttp().get<ApiResponse<HeatmapPoint[]>>(
`stats/gitea/${GITEA_USER}/heatmap`,
{
timeout: 5000,
retry: 0,
},
);
if (Array.isArray(data)) heatmap = data;
} catch (error) {
// 统计接口不可用时不影响入口页展示
console.error("[embed/gitea] 热力图数据获取失败", error);
}
const entries = [
{ label: "博客地址", desc: "ua42.com", href: "https://ua42.com" },
{
label: "博客管理后台",
desc: "admin.ua42.com · 支持游客查看",
href: "https://admin.ua42.com",
},
{
label: "仓库地址",
desc: "git.ua42.com/beggin",
href: "https://git.ua42.com/beggin",
},
{
label: "博客服务端仓库",
desc: "git.ua42.com/beggin/blog-server",
href: "https://git.ua42.com/beggin/blog-server",
},
{
label: "博客服务端 API 文档",
desc: "dev.ua42.com/docs",
href: "https://dev.ua42.com/docs/server-documentation.html",
},
{
label: "Panda Dock",
desc: "github.com/forestRhapsody/panda-dock",
href: "https://github.com/forestRhapsody/panda-dock",
},
];
--- ---
<!doctype html> <!doctype html>
@@ -15,7 +66,7 @@ import {metadata} from '@/consts.ts'
<meta name="generator" content={Astro.generator} /> <meta name="generator" content={Astro.generator} />
<title>Gitea 入口</title> <title>Gitea 入口</title>
<meta name="theme-color" content="#ffffff" /> <meta name="theme-color" content="#ffffff" />
<meta name="robots" content="noindex, nofollow"> <meta name="robots" content="noindex, nofollow" />
<style> <style>
@import "modern-normalize"; @import "modern-normalize";
@@ -28,7 +79,9 @@ import {metadata} from '@/consts.ts'
--primary: #4f6df5; --primary: #4f6df5;
} }
* { *,
*::before,
*::after {
box-sizing: border-box; box-sizing: border-box;
} }
@@ -37,104 +90,165 @@ import {metadata} from '@/consts.ts'
min-height: 100vh; min-height: 100vh;
background: var(--bg); background: var(--bg);
color: var(--text-color); color: var(--text-color);
font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; font-family:
system-ui,
-apple-system,
"Segoe UI",
"PingFang SC",
"Microsoft YaHei",
sans-serif;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
} }
.page-container { .page-container {
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 24px 24px 24px 24px;
}
.gitea-card {
width: 100%; width: 100%;
max-width: 520px; max-width: 900px;
background: var(--card-bg); min-height: 100vh;
border: 1px solid var(--border); margin: 0 auto;
border-radius: 10px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
overflow: hidden;
}
.gitea-card__title {
padding: 14px 20px;
font-size: 15px;
font-weight: 600;
border-bottom: 1px solid var(--border);
}
.gitea-content {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center;
gap: 28px;
padding: 24px;
} }
.gitea-item { .section {
width: 100%;
}
.section__head {
display: flex; display: flex;
align-items: center; align-items: baseline;
justify-content: space-between; justify-content: space-between;
gap: 16px; gap: 12px;
padding: 13px 20px; margin-bottom: 10px;
font-size: 14px; padding: 0 2px;
} }
.gitea-item + .gitea-item { .section__title {
border-top: 1px solid var(--border); margin: 0;
font-size: 15px;
font-weight: 600;
line-height: 1.4;
} }
.gitea-item:hover { .section__meta {
background: #fafbfc; font-size: 12px;
}
.gitea-item__label {
color: var(--text-secondary); color: var(--text-secondary);
} }
.gitea-item__link { .entry-grid {
color: var(--primary); display: grid;
text-decoration: none; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
white-space: nowrap; gap: 12px;
} }
.gitea-item__link:hover { .entry {
text-decoration: underline; position: relative;
display: flex;
flex-direction: column;
gap: 4px;
padding: 14px 40px 14px 16px;
background: var(--card-bg);
border: 1px solid var(--border);
border-radius: 10px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
color: inherit;
text-decoration: none;
transition:
border-color 0.15s ease,
box-shadow 0.15s ease,
transform 0.15s ease;
}
.entry:hover {
border-color: #c7d2fe;
box-shadow: 0 4px 14px rgba(79, 109, 245, 0.12);
transform: translateY(-1px);
}
.entry__label {
font-size: 14px;
font-weight: 500;
line-height: 1.4;
}
.entry__desc {
overflow: hidden;
font-size: 12px;
color: var(--text-secondary);
white-space: nowrap;
text-overflow: ellipsis;
}
.entry__arrow {
position: absolute;
top: 14px;
right: 16px;
font-size: 13px;
line-height: 1;
color: var(--text-secondary);
transition:
color 0.15s ease,
transform 0.15s ease;
}
.entry:hover .entry__arrow {
color: var(--primary);
transform: translate(1px, -1px);
}
.card {
width: 100%;
background: var(--card-bg);
border: 1px solid var(--border);
border-radius: 10px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
overflow: hidden;
}
@media (max-width: 640px) {
.page-container {
gap: 20px;
padding: 16px;
}
} }
</style> </style>
</head> </head>
<body> <body>
<div class="page-container"> <div class="page-container">
<div class="gitea-card"> <section class="section">
<div class="gitea-card__title">常用入口</div> <div class="section__head">
<div class="gitea-content"> <h2 class="section__title">常用入口</h2>
<div class="gitea-item">
<span class="gitea-item__label">博客地址</span>
<a class="gitea-item__link" target="_blank" href="https://ua42.com">点击访问</a>
</div> </div>
<div class="entry-grid">
{entries.map(({ label, desc, href }) => (
<a
class="entry"
href={href}
target="_blank"
rel="noopener noreferrer"
>
<span class="entry__label">{label}</span>
<span class="entry__desc">{desc}</span>
<span class="entry__arrow" aria-hidden="true">
↗
</span>
</a>
))}
</div>
</section>
<div class="gitea-item"> {heatmap.length > 0 && (
<span class="gitea-item__label">博客管理后台(支持游客查看)</span> <section class="section">
<a class="gitea-item__link" target="_blank" href="https://admin.ua42.com">点击访问</a> <div class="section__head">
</div> <h2 class="section__title">代码贡献</h2>
<div class="gitea-item">
<span class="gitea-item__label">仓库地址</span>
<a class="gitea-item__link" target="_blank" href="https://git.ua42.com/beggin">点击访问</a>
</div>
<div class="gitea-item">
<span class="gitea-item__label">博客服务端仓库</span>
<a class="gitea-item__link" target="_blank" href="https://git.ua42.com/beggin/blog-server">点击访问</a>
</div>
<div class="gitea-item">
<span class="gitea-item__label">博客服务端 API文档</span>
<a class="gitea-item__link" target="_blank" href="https://dev.ua42.com/docs/server-documentation.html">点击访问</a>
</div>
</div> </div>
<div class="card">
<ContributionHeatmap points={heatmap} />
</div> </div>
</section>
)}
</div> </div>
</body> </body>
</html> </html>

View File

@@ -1,505 +0,0 @@
---
import Layout from "@/layouts/Layout.astro";
import Calendar from "@/assets/icon/calendar.png?url";
import Eye from "@/assets/icon/eye.png?url";
import Folder from "@/assets/icon/folder.png?url";
import { formatDatetime } from "@/lib/format.ts";
import { createHttp } from "@/lib/request";
import type { CategoriesStats, Post, Tag } from "@/types";
import LazyImage from "@/components/LazyImage.astro";
const http = createHttp(Astro.request.headers);
const searchParams = Astro.url.searchParams;
const type = searchParams.get("type") ?? "";
const code = searchParams.get("code") ?? "";
/**
* 搜索接口返回结构:tags 为 base64 编码的 JSON 字符串、
* 阅读数字段为 views,且不含 cover / content,这里做归一化
*/
type SearchPost = Omit<Post, "view" | "tags" | "cover" | "content"> & {
views: number;
tags: string;
cover?: string;
content?: string;
};
const decodeTags = (raw: string): Tag[] => {
try {
return JSON.parse(Buffer.from(raw, "base64").toString("utf8")) as Tag[];
} catch {
return [];
}
};
const normalizePost = (post: SearchPost): Post => ({
...post,
view: post.views,
tags: decodeTags(post.tags),
cover: post.cover ?? "",
content: post.content ?? "",
});
const [{ data: categories }, { data: allTags }, { data: rawPosts }] = await Promise.all([
http.get<ApiResponse<CategoriesStats[]>>("categories/stats"),
http.get<ApiResponse<Tag[]>>("posts/tags"),
http.get<ApiResponse<SearchPost[]>>("posts/search", {
searchParams: {
category_code: type === "category" ? code : "",
tag_code: type === "tag" ? code : "",
},
}),
]);
const searchPosts = rawPosts.map(normalizePost);
const category =
type === "category" ? categories.find((item) => item.code === code) : undefined;
/** 展示全部标签,按名称排序 */
const tags = [...allTags].sort((a, b) => a.name.localeCompare(b.name, "zh-CN"));
const tag = type === "tag" ? tags.find((item) => item.code === code) : undefined;
const valid = Boolean(category || tag);
const posts = searchPosts;
const filterLabel = category ? "分类" : tag ? "标签" : "";
const filterTitle = category?.name ?? tag?.name ?? "";
const count = category ? category.post_count : posts.length;
const pageTitle = valid ? `${filterLabel}:${filterTitle}` : "筛选";
const pageDescription = valid
? `${filterLabel}「${filterTitle}」下的文章,共 ${count} 篇`
: "按分类或标签筛选文章";
const filterUrl = (type: string, code: string) =>
`/filter?type=${type}&code=${encodeURIComponent(code)}`;
const isActive = (targetType: string, targetCode: string) =>
type === targetType && code === targetCode;
---
<Layout title={pageTitle} description={pageDescription}>
<div class="page-content">
<div class="filter-page">
<header class="filter-header">
{
valid ? (
<>
<span class="filter-badge">{filterLabel}</span>
<h1 class="filter-title">{filterTitle}</h1>
<span class="filter-count">共 {count} 篇</span>
</>
) : (
<>
<h1 class="filter-title">未找到该筛选条件</h1>
<p class="filter-tip">请从下方分类或标签进入</p>
</>
)
}
<a class="filter-back" href="/">返回首页</a>
</header>
<nav class="filter-nav" aria-label="筛选导航">
<div class="nav-group">
<span class="nav-label">分类</span>
<div class="nav-chips">
{
categories.map((item) => (
<a
class={isActive("category", item.code) ? "chip active" : "chip"}
href={filterUrl("category", item.code)}
>
{item.name}
<em>{item.post_count}</em>
</a>
))
}
</div>
</div>
<div class="nav-group">
<span class="nav-label">标签</span>
<div class="nav-chips">
{
tags.map((item) => (
<a
class={isActive("tag", item.code) ? "chip active" : "chip"}
href={filterUrl("tag", item.code)}
>
{item.name}
</a>
))
}
</div>
</div>
</nav>
{
valid &&
(posts.length > 0 ? (
<ul class="post-list">
{
posts.map((post) => (
<li class="post-card">
<a class="post-cover" href={`/post/${post.slug}`} aria-label={post.title}>
{post.cover ? (
<LazyImage src={post.cover} alt={post.title} />
) : (
<span class="cover-placeholder">{post.title[0]}</span>
)}
</a>
<div class="post-body">
<div class="post-meta">
<span>
<img src={Calendar} alt="Calendar" />
{formatDatetime(post.published_at, "YYYY-MM-DD")}
</span>
<span>
<img src={Folder} alt="Folder" />
{post.category_name}
</span>
<span>
<img src={Eye} alt="Eye" />
{post.view}
</span>
</div>
<h3 class="post-title">
<a href={`/post/${post.slug}`}>{post.title}</a>
</h3>
<p class="post-summary">{post.summary}</p>
<div class="tags">
{
post.tags.map((item) => (
<span class="tag">{item.name}</span>
))
}
</div>
</div>
</li>
))
}
</ul>
) : (
<div class="filter-empty">
<p class="empty-text">无数据</p>
</div>
))
}
</div>
</div>
</Layout>
<style>
.filter-page {
max-width: 860px;
margin: 0 auto;
display: flex;
flex-direction: column;
gap: 14px;
}
.filter-header {
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
background: var(--card-bg);
border-radius: 10px;
box-shadow: var(--shadow);
padding: 16px 20px;
}
.filter-badge {
flex-shrink: 0;
font-size: 12px;
color: #fff;
background: linear-gradient(135deg, #4f6df5, #7b5cf0);
padding: 3px 10px;
border-radius: 999px;
}
.filter-title {
font-size: 20px;
font-weight: 700;
margin: 0;
}
.filter-count {
font-size: 13px;
color: var(--text-secondary);
}
.filter-tip {
margin: 0;
font-size: 14px;
color: var(--text-secondary);
}
.filter-back {
margin-left: auto;
font-size: 14px;
color: var(--text-secondary);
transition: color 0.2s;
}
.filter-back:hover {
color: var(--primary);
}
/* 分类 / 标签导航 */
.filter-nav {
background: var(--card-bg);
border-radius: 10px;
box-shadow: var(--shadow);
padding: 14px 18px;
display: flex;
flex-direction: column;
gap: 10px;
}
.nav-group {
display: flex;
align-items: flex-start;
gap: 10px;
}
.nav-label {
flex-shrink: 0;
font-size: 13px;
color: var(--text-secondary);
line-height: 26px;
}
.nav-chips {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.chip {
display: inline-flex;
align-items: center;
gap: 5px;
font-size: 12px;
color: var(--tag-text);
background: var(--tag-bg);
padding: 4px 12px;
border-radius: 999px;
text-decoration: none;
border: 1px solid transparent;
transition: background 0.2s;
}
.chip:hover {
background: var(--tag-hover-bg);
}
.chip.active {
background: var(--primary);
border-color: var(--primary);
color: #fff;
}
.chip em {
font-style: normal;
font-size: 11px;
opacity: 0.7;
}
/* 文章列表(与首页 PostList 样式统一) */
.post-list {
list-style: none;
display: flex;
flex-direction: column;
gap: 20px;
}
.post-card {
background: var(--card-bg);
border-radius: 12px;
box-shadow: var(--shadow);
padding: 16px;
transition: transform 0.2s, box-shadow 0.2s;
display: flex;
gap: 22px;
}
@media (hover: hover) and (pointer: fine) {
.post-card:hover {
transform: translateY(-3px);
box-shadow: var(--shadow-hover);
}
}
.post-cover {
flex-shrink: 0;
width: 160px;
height: 100px;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
font-size: 40px;
color: #fff;
overflow: hidden;
}
.post-cover img {
width: 100%;
height: 100%;
object-fit: cover;
}
.cover-placeholder {
font-size: 40px;
font-weight: 700;
color: #fff;
}
.post-body {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
}
.post-meta {
font-size: 12px;
color: var(--text-secondary);
margin-bottom: 6px;
display: flex;
gap: 14px;
flex-wrap: wrap;
}
.post-meta span {
display: flex;
align-items: center;
gap: 4px;
}
.post-meta span img {
width: 14px;
height: 14px;
display: block;
}
.post-title {
margin: 0 0 8px;
font-size: 20px;
font-weight: 700;
line-height: 1.4;
}
.post-title a {
color: inherit;
text-decoration: none;
}
.post-title a:hover {
color: var(--primary);
}
:global(.dark) .post-title a:hover {
color: inherit;
}
.post-summary {
margin: 0 0 12px;
font-size: 14px;
color: var(--text-secondary);
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.tags {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: auto;
}
.tag {
font-size: 12px;
color: var(--tag-text);
background: var(--tag-bg);
padding: 3px 10px;
border-radius: 999px;
transition: background 0.2s;
}
@media (hover: hover) and (pointer: fine) {
.tag:hover {
background: var(--tag-hover-bg);
}
}
.filter-empty {
background: var(--card-bg);
border-radius: 10px;
box-shadow: var(--shadow);
padding: 32px 20px;
text-align: center;
}
.empty-text {
margin: 0;
font-size: 13px;
color: var(--text-secondary);
}
@media (max-width: 860px) {
.post-list {
gap: 16px;
}
.post-card {
padding: 16px;
gap: 12px;
}
.post-cover {
width: 128px;
height: 80px;
}
.post-title {
font-size: 18px;
}
.post-meta {
gap: 8px;
font-size: 12px;
}
}
@media (max-width: 560px) {
.post-card {
padding: 12px;
}
.post-title {
font-size: 16px;
margin-bottom: 4px;
}
.post-meta {
gap: 6px;
font-size: 12px;
}
.post-cover {
width: 100px;
height: 62px;
}
.post-summary {
font-size: 12px;
margin-bottom: 6px;
}
}
</style>

View File

@@ -1,25 +1,23 @@
--- ---
import Layout from "@/layouts/Layout.astro"; import Layout from "@/layouts/Layout.astro";
import IndexView from "@/components/IndexView.astro"; import {siteConfig} from "@/consts.ts";
import type { Post } from "@/types/post"; import {createHttp} from "@/lib/request.ts";
import { createHttp } from "@/lib/request"; import type {Post} from "@/types";
import { metadata } from "@/consts.ts"; import IndexPage from "@/components/IndexPage.astro";
const {postPageSize, description} = siteConfig;
const http = createHttp(Astro.request.headers); const http = createHttp(Astro.request.headers);
const {list, total} = await http.get<ApiPageResponse<Post>>("posts", { const {list, total} = await http.get<ApiPageResponse<Post>>("posts", {
searchParams: { searchParams: {
page: 1, page: 1,
page_size: metadata.postPageSize, page_size: postPageSize,
}, },
}); });
const totalPage = Math.ceil(total / metadata.postPageSize); const totalPage = Math.ceil(total / postPageSize);
--- ---
<Layout description="天若有情天亦老,人间正道是沧桑。" title="博客首页"> <Layout title="博客首页" description={description}>
<IndexView <IndexPage page={1} totalPage={totalPage} posts={list}/>
posts={list}
page={1}
totalPage={totalPage}
/>
</Layout> </Layout>

View File

@@ -1,36 +1,34 @@
--- ---
import Layout from "@/layouts/Layout.astro"; import Layout from "@/layouts/Layout.astro";
import type { Post } from "@/types/post"; import {siteConfig} from "@/consts.ts";
import { createHttp } from "@/lib/request"; import {createHttp} from "@/lib/request.ts";
import { metadata } from "@/consts.ts"; import type {Post} from "@/types";
import IndexView from "@/components/IndexView.astro"; import IndexPage from "@/components/IndexPage.astro";
const {page} = Astro.params; const {page} = Astro.params;
if (isNaN(Number(page))) { const pageInt = Number(page);
if (isNaN(pageInt) || pageInt <= 1) {
return Astro.redirect("/"); return Astro.redirect("/");
} }
const {postPageSize, description} = siteConfig;
const http = createHttp(Astro.request.headers); const http = createHttp(Astro.request.headers);
const {list, total} = await http.get<ApiPageResponse<Post>>("posts", { const {list, total} = await http.get<ApiPageResponse<Post>>("posts", {
searchParams: { searchParams: {
page, page: pageInt,
page_size: metadata.postPageSize, page_size: postPageSize,
}, },
}); });
const totalPage = Math.ceil(total / postPageSize);
const totalPage = Math.ceil(total / metadata.postPageSize); if (totalPage < pageInt) {
if (totalPage < Number(page)) {
return Astro.redirect("/404"); return Astro.redirect("/404");
} }
--- ---
<Layout description="天若有情天亦老,人间正道是沧桑。" title="博客首页"> <Layout title="博客首页" description={description}>
<IndexView <IndexPage page={pageInt} totalPage={totalPage} posts={list}/>
posts={list}
page={Number(page)}
totalPage={totalPage}
/>
</Layout> </Layout>

View File

@@ -4,158 +4,160 @@ import "@/styles/github-markdown-reset.css";
import "photoswipe/dist/photoswipe.css"; import "photoswipe/dist/photoswipe.css";
import Layout from "@/layouts/Layout.astro"; import Layout from "@/layouts/Layout.astro";
import Toc from "@/components/Post/Toc.astro";
import { createHttp } from "@/lib/request.ts"; import { createHttp } from "@/lib/request.ts";
import { highlightHtmlWithJsdom } from "@/lib/highlight.js";
import { formatDatetime } from "@/lib/format.ts";
import type { Post } from "@/types"; import type { Post } from "@/types";
import { processHtmlWithJsdom } from "@/lib/processHtml.ts";
import { formatDatetime } from "@/lib/format.ts";
const { slug } = Astro.params; const { slug } = Astro.params;
let data: Post;
const http = createHttp(Astro.request.headers); const http = createHttp(Astro.request.headers);
let data: Post;
try { try {
const res = await http.get<ApiResponse<Post>>(`posts/${slug}`); const res = await http.get<ApiResponse<Post>>(`posts/${slug}`);
data = res.data; data = res.data;
} catch (error) { } catch (error) {
return Astro.redirect("/404"); return Astro.redirect("/404");
} }
const content = await highlightHtmlWithJsdom(data.content);
const published_at = formatDatetime(data.published_at, "YYYY 年 M 月 D 日"); const { html, toc } = await processHtmlWithJsdom(data.content);
const published_at = formatDatetime(data.published_at, "YYYY.MM.DD");
--- ---
<Layout title={data.title} description={data.summary}> <Layout title={data.title} description={data.summary}>
<div class="page-content"> <div class="post-wrap">
<div class="post"> <article>
<h1 class="post-title">{data.title}</h1> <div class="meta">
<div class="meta-left">
<div class="post-meta"> <span>{data.category_name} · {data.category_code.toUpperCase()}</span>
<div class="published-at"> <span>{published_at}</span>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="lucide lucide-calendar-days-icon lucide-calendar-days"
>
<path d="M8 2v4"></path>
<path d="M16 2v4"></path>
<rect width="18" height="18" x="3" y="4" rx="2"></rect>
<path d="M3 10h18"></path>
<path d="M8 14h.01"></path>
<path d="M12 14h.01"></path>
<path d="M16 14h.01"></path>
<path d="M8 18h.01"></path>
<path d="M12 18h.01"></path>
<path d="M16 18h.01"></path>
</svg>
{published_at}
</div> </div>
<div class="post-view"> <div class="meta-view-count">{data.view_count} 次阅读</div>
<svg
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="5122"
>
<path
d="M509.618 415.795c-42.695 0-77.253 38.372-77.253 85.738 0 47.352 34.558 86.22 77.253 86.22 42.667 0 76.716-38.867 76.716-86.22 0-47.352-34.049-85.738-76.716-85.738z m1.9-177.9c-211.548 0-383.265 159.859-383.265 274.587 0 114.727 171.717 273.624 383.266 273.624 212.484 0 384.227-162.522 384.227-273.624 0-111.088-171.743-274.587-384.227-274.587z m-1.446 452.006c-89.7 0-162.134-81.71-162.134-181.903 0-101.157 72.435-182.397 162.134-182.397 90.183 0 163.1 81.241 163.1 182.397 0 100.206-72.917 181.903-163.1 181.903z"
p-id="5123"></path>
</svg>
{data.view}
</div>
</div> </div>
<h1 class="title">{data.title}</h1>
<div class="markdown-body" data-color-mode="dark" set:html={content} /> {
data.cover && (
<div>
<img class="cover" src={data.cover} alt={data.title} />
</div> </div>
)
}
<p class="summary">{data.summary}</p>
<div class="divider"></div>
<div class="markdown-body" data-color-mode="dark" set:html={html} />
{
data.tags.length > 0 && (
<div class="tags">
{data.tags.map((tag) => (
<span>{tag.name}</span>
))}
</div>
)
}
</article>
{toc.length > 0 && <Toc toc={toc} />}
</div> </div>
</Layout> </Layout>
<style> <style>
.post { .post-wrap {
background: #fff; position: relative;
border-radius: 12px; flex: 1;
overflow: auto; flex-shrink: 0;
padding: 24px; width: 100%;
box-shadow: var(--shadow);
} }
.post-title { .cover {
margin-bottom: 16px; width: 100%;
font-size: 32px;
}
.post-meta {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 20px; margin-bottom: 20px;
} }
.published-at { .meta {
display: flex; color: var(--text-meta);
align-items: center;
gap: 8px;
color: #6b7280;
font-size: 14px; font-size: 14px;
}
.published-at svg {
width: 18px;
height: 18px;
}
:global(.markdown-body img) {
object-fit: contain;
height: auto !important;
}
.post-view {
display: flex; display: flex;
justify-content: space-between;
align-items: center; align-items: center;
gap: 4px; margin-bottom: 20px;
color: #6b7280; }
padding-right: 12px;
.meta-left {
display: flex;
gap: 16px;
flex-wrap: wrap;
}
.meta-view-count:hover {
color: var(--text-primary);
}
.title {
font-size: 36px;
line-height: 1.4;
margin-bottom: 20px;
color: var(--text-primary);
font-weight: bold;
}
.summary {
font-size: 14px; font-size: 14px;
margin-bottom: 20px;
color: var(--text-summary);
line-height: 1.4;
} }
.post-view svg { .divider {
width: 20px; border-bottom: var(--border-secondary);
height: 20px;
fill: currentColor; /* 让填充跟随 color */
stroke: currentColor; /* 让描边也跟随 color */
} }
@media (max-width: 768px) { .markdown-body {
.post-title { margin-top: 24px;
font-size: 20px; line-height: 1.8;
font-size: 16px;
color: var(--article-text-color);
} }
.post { .tags {
padding: 12px; margin-top: 24px;
} display: flex;
gap: 10px;
flex-wrap: wrap;
} }
:global(.dark) .post { .tags span {
background: var(--card-bg); font-size: 12px;
box-shadow: none; color: var(--text-secondary);
border: none; border: var(--border-primary);
border-radius: 20px;
padding: 8px 16px;
}
@media (max-width: 640px) {
.title {
font-size: 30px;
}
} }
</style> </style>
<script> <script>
import PhotoSwipeLightbox from "photoswipe/lightbox"; import PhotoSwipeLightbox from "photoswipe/lightbox";
import ClipboardJS from "clipboard";
const init = async () => { const init = async () => {
const post = document.querySelector(".post")!; const article = document.querySelector(".markdown-body")!;
const images = Array.from(post.querySelectorAll("img")); const images = Array.from(article.querySelectorAll("img"));
if (images.length === 0) return;
const waitImageLoaded = (img: HTMLImageElement) => { const waitImageLoaded = (img: HTMLImageElement) => {
if (img.complete && img.naturalWidth > 0 && img.naturalHeight > 0) { if (img.complete && img.naturalWidth > 0 && img.naturalHeight > 0) {
@@ -190,7 +192,7 @@ const published_at = formatDatetime(data.published_at, "YYYY 年 M 月 D 日");
); );
const lightbox = new PhotoSwipeLightbox({ const lightbox = new PhotoSwipeLightbox({
gallery: ".post", gallery: ".markdown-body",
children: "a[data-pswp-width]", children: "a[data-pswp-width]",
pswpModule: () => import("photoswipe"), pswpModule: () => import("photoswipe"),
@@ -209,4 +211,37 @@ const published_at = formatDatetime(data.published_at, "YYYY 年 M 月 D 日");
}; };
init(); init();
const copyTimers = new WeakMap<HTMLElement, ReturnType<typeof setTimeout>>();
// 代码块复制功能
const clipboard = new ClipboardJS(".code-copy-btn", {
text: (el) => {
const sibling = el.closest(".code-header")?.nextElementSibling;
return sibling?.textContent.trim() || "";
},
});
clipboard.on("success", (e) => {
const btn = e.trigger as HTMLElement;
// 清理当前按钮之前的定时器
const oldTimer = copyTimers.get(btn);
if (oldTimer) {
clearTimeout(oldTimer);
}
const originalText = btn.textContent || "";
btn.textContent = "✓ 代码已复制";
const timer = setTimeout(() => {
btn.textContent = originalText;
copyTimers.delete(btn);
}, 2000);
copyTimers.set(btn, timer);
e.clearSelection();
});
</script> </script>

View File

@@ -0,0 +1,32 @@
import type {APIRoute} from 'astro';
import {siteConfig} from "@/consts";
const site = siteConfig.site
const staticUrls = [
'',
'/archive'
];
export const GET: APIRoute = async () => {
const urls = staticUrls
.filter((url, index, array) => {
return array.indexOf(url) === index;
});
const xml = `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${urls.map((url) => `<url>
<loc>${site}${url}</loc>
</url>`
)
.join('\n')}
</urlset>`;
return new Response(xml, {
status: 200,
headers: {
'Content-Type': 'application/xml; charset=utf-8',
'Cache-Control': 'public, max-age=3600, s-maxage=3600',
},
});
};

View File

@@ -0,0 +1,35 @@
import type {APIRoute} from 'astro';
import {siteConfig} from "@/consts";
import {createHttp} from "@/lib/request.ts";
import type {PostForSitemap} from "@/types";
import dayjs from "dayjs";
const site =siteConfig.site
export const GET: APIRoute = async (context) => {
const http = createHttp(context.request.headers);
const {data} = await http.get<ApiResponse<PostForSitemap[]>>("posts/sitemap")
const urls = data
.filter((url, index, array) => {
return array.indexOf(url) === index;
});
const xml = `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${urls.map((post) => `<url>
<loc>${site}/post/${post.slug}</loc>
<lastmod>${dayjs(post.updated_at || post.created_at).toISOString()}</lastmod>
</url>`
)
.join('\n')}
</urlset>`;
return new Response(xml, {
status: 200,
headers: {
'Content-Type': 'application/xml; charset=utf-8',
'Cache-Control': 'public, max-age=3600, s-maxage=3600',
},
});
};

21
src/pages/sitemap.xml.ts Normal file
View File

@@ -0,0 +1,21 @@
import type {APIRoute} from 'astro';
import {siteConfig} from "@/consts";
const site = siteConfig.site
export const GET: APIRoute = () => {
const xml = `<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>${site}/sitemap-pages.xml</loc>
</sitemap>
<sitemap>
<loc>${site}/sitemap-posts.xml</loc>
</sitemap>
</sitemapindex>`;
return new Response(xml, {
headers: {
'Content-Type': 'application/xml; charset=utf-8',
},
});
};

View File

@@ -7,3 +7,7 @@ a {
color: inherit; color: inherit;
text-decoration: none; text-decoration: none;
} }
ul,li{
list-style: none;
}

View File

@@ -1,5 +1,6 @@
.markdown-body pre code { .markdown-body pre code {
font-size: 1.1em; font-size: 14px;
line-height: 1.6;
} }
.markdown-body h1, .markdown-body h1,
@@ -16,3 +17,68 @@
font-size: inherit; font-size: inherit;
} }
} }
.markdown-body .highlight pre,
.markdown-body pre {
border-radius: 0 0 8px 8px;
}
.markdown-body img {
margin: 12px 0 12px;
}
.code-block {
}
.code-header {
height: 36px;
background: var(--code-block-header-bg);
display: flex;
justify-content: space-between;
color: var(--text-primary);
align-items: center;
padding: 0 12px;
font-size: 14px;
border-radius: 8px 8px 0 0;
}
.code-header-left {
display: flex;
align-items: center;
gap: 12px;
}
.code-actions {
display: flex;
align-items: center;
gap: 7px;
}
.code-actions .dot {
width: 12px;
height: 12px;
border-radius: 50%;
display: block;
}
.code-actions .close {
background: #ff5f57;
}
.code-actions .minimize {
background: #febc2e;
}
.code-actions .maximize {
background: #28c840;
}
.code-copy-btn {
font-size: 12px;
cursor: pointer;
user-select: none;
}
.code-copy-btn:hover {
color: var(--code-block-copy-btn-hover-color);
}

View File

@@ -2,60 +2,72 @@
@import "css-reset.css"; @import "css-reset.css";
:root { :root {
--layout-width: 1080px; --font-family:
--background: #f6f7f9; -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
--shadow: 0 2px 8px rgba(0, 0, 0, 0.06); "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial,
--shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.10); sans-serif;
--card-bg: #ffffff; --layout-width: 760px;
--text-color: #2b2f36;
--text-secondary: #6b7280; --background: #ffffff;
--border: #e5e7eb; --border-primary: 1px solid #dcdcdc;
--primary: #4f6df5; --border-secondary: 1px solid #eee;
--tag-bg: #eef1fe; --text-primary: #030712;
--tag-text: #4f6df5; --text-secondary: #3f3f46;
--tag-hover-bg: #dfe6fd; --text-disabled: #d1d5db;
--text-meta: #71717a;
--article-text-color: #1e1e1e;
--text-title-hover: #000;
--code-block-header-bg: #f5f5f4;
--code-block-copy-btn-hover-color: #6b7280;
--text-summary: #000;
} }
.dark { .dark {
--background: #0a0a0a; --background: #0a0a0a;
--card-bg: #161b22; --border-primary: 1px solid #52525b;
--text-color: #ffffff; --border-secondary: 1px solid #525252;
--text-secondary: #e5e7eb; --text-primary: #e4e4e7;
--border: #e5e7eb; --text-secondary: #d1d5db;
--primary: #1e293b; --text-disabled: #6b7280;
--tag-bg: #27272a; --text-meta: #d4d4d8;
--tag-text: #f3f4f6; --article-text-color: #d4d4d8;
--tag-hover-bg: #334155; --text-title-hover: #fff;
--code-block-header-bg: #374151;
--code-block-copy-btn-hover-color: #9ca3af;
--text-summary: #fff;
}
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
/* 滚动条轨道 */
::-webkit-scrollbar-track {
background: transparent;
}
/* 滚动条滑块 */
::-webkit-scrollbar-thumb {
background: rgba(139, 139, 139, 0.5);
border-radius: 999px;
}
/* 鼠标悬停 */
::-webkit-scrollbar-thumb:hover {
background: rgba(139, 139, 139, 0.7);
} }
html, html,
body { body {
min-height: 100vh;
font-size: 16px;
background: var(--background);
color: var(--text-color);
}
body {
display: flex;
flex-direction: column;
}
.main {
flex: 1;
display: flex;
flex-direction: column;
}
.page-content {
width: 100%; width: 100%;
max-width: var(--layout-width); height: 100%;
margin: 0 auto; min-height: 100%;
padding: 32px; font-family: var(--font-family), serif;
color: var(--text-primary);
background: var(--background);
} }
@media (max-width: 768px) { html {
.page-content { scroll-behavior: smooth;
padding: 16px;
}
} }

View File

View File

@@ -3,6 +3,7 @@ export type Tag = {
code: string code: string
name: string name: string
} }
export type Post = { export type Post = {
title: string; title: string;
summary: string; summary: string;
@@ -12,7 +13,7 @@ export type Post = {
category_code: string; category_code: string;
category_id?: number; category_id?: number;
published_at: string; published_at: string;
view: number; view_count: number;
content: string; content: string;
tags: Tag[] tags: Tag[]
} }
@@ -23,3 +24,9 @@ export type CategoriesStats = {
code: string code: string
post_count: number; post_count: number;
} }
export type PostForSitemap = {
slug: string
created_at: string
updated_at: string
}

7
src/types/stats.ts Normal file
View File

@@ -0,0 +1,7 @@
/** Gitea 贡献热力图接口返回的原始数据点 */
export type HeatmapPoint = {
/** Unix 秒级时间戳 */
timestamp: number
/** 该时间点产生的贡献次数 */
contributions: number
}

View File

@@ -13,8 +13,6 @@
"@/*": [ "@/*": [
"src/*" "src/*"
] ]
}, }
"jsx": "preserve",
"jsxImportSource": "solid-js"
} }
} }