Skip to content

Commit 67c0571

Browse files
author
CMSZ
committed
feat: 添加随笔页面和初始数据文件
- 创建 notes.yml 数据文件,用于存储随笔内容 - 实现 notes.astro 页面,包含时间线展示、图片支持和响应式设计 - 添加 Markdown 渲染、时间格式化和分组加载功能 - 包含统计信息和国际化支持
1 parent f4c99c6 commit 67c0571

File tree

15 files changed

+370
-392
lines changed

15 files changed

+370
-392
lines changed

astro.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import remarkDirective from "remark-directive"; /* Handle directives */
1515
import remarkGithubAdmonitionsToDirectives from "remark-github-admonitions-to-directives";
1616
import remarkMath from "remark-math";
1717
import remarkSectionize from "remark-sectionize";
18+
import yaml from "@rollup/plugin-yaml";
1819
import { expressiveCodeConfig } from "./src/config.ts";
1920
import { pluginLanguageBadge } from "./src/plugins/expressive-code/language-badge.ts";
2021
import { AdmonitionComponent } from "./src/plugins/rehype-component-admonition.mjs";
@@ -156,6 +157,7 @@ export default defineConfig({
156157
],
157158
},
158159
vite: {
160+
plugins: [yaml()],
159161
build: {
160162
rollupOptions: {
161163
onwarn(warning, warn) {

src/config.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,7 @@ export const navBarConfig: NavBarConfig = {
4848
{
4949
name: "我的",
5050
url: "",
51-
children: [
52-
LinkPreset.About,
53-
{
54-
name: "日记",
55-
url: "/diary/",
56-
},
57-
],
51+
children: [LinkPreset.Notes, LinkPreset.About],
5852
},
5953
{
6054
name: "统计",

src/constants/link-presets.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ export const LinkPresets: { [key in LinkPreset]: NavBarLink } = {
1515
name: i18n(I18nKey.archive),
1616
url: "/archive/",
1717
},
18+
[LinkPreset.Notes]: {
19+
name: i18n(I18nKey.notes),
20+
url: "/notes/",
21+
},
1822
};

src/data/diary.ts

Lines changed: 0 additions & 90 deletions
This file was deleted.

src/data/notes.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- id: 1
2+
content: "删库跑路!"
3+
date: "2026-02-09T08:40:00Z"

src/env.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
11
/// <reference types="astro/client" />
22
/// <reference path="../.astro/types.d.ts" />
3+
4+
declare module "*.yml" {
5+
const data: unknown;
6+
export default data;
7+
}
8+
9+
declare module "*.yaml" {
10+
const data: unknown;
11+
export default data;
12+
}

src/global.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,13 @@ interface SearchResult {
3939
raw_url?: string;
4040
sub_results?: SearchResult[];
4141
}
42+
43+
declare module "*.yml" {
44+
const data: unknown;
45+
export default data;
46+
}
47+
48+
declare module "*.yaml" {
49+
const data: unknown;
50+
export default data;
51+
}

src/i18n/i18nKey.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,14 @@ enum I18nKey {
6666
atomCopied = "atomCopied",
6767
atomCopyFailed = "atomCopyFailed",
6868

69-
// 短文页面
70-
diary = "diary",
71-
diarySubtitle = "diarySubtitle",
72-
diaryCount = "diaryCount",
73-
diaryReply = "diaryReply",
74-
diaryTips = "diaryTips",
75-
diaryMinutesAgo = "diaryMinutesAgo",
76-
diaryHoursAgo = "diaryHoursAgo",
77-
diaryDaysAgo = "diaryDaysAgo",
69+
// 随笔页面
70+
notes = "notes",
71+
notesSubtitle = "notesSubtitle",
72+
notesCount = "notesCount",
73+
notesReply = "notesReply",
74+
notesMinutesAgo = "notesMinutesAgo",
75+
notesHoursAgo = "notesHoursAgo",
76+
notesDaysAgo = "notesDaysAgo",
7877
}
7978

8079
export default I18nKey;

src/i18n/languages/en.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,12 @@ export const en: Translation = {
7878
[Key.atomCopied]: "Atom link copied to clipboard!",
7979
[Key.atomCopyFailed]: "Copy failed, please copy the link manually",
8080

81-
// Diary Page
82-
[Key.diary]: "Diary",
83-
[Key.diarySubtitle]: "Share life, anytime, anywhere",
84-
[Key.diaryCount]: "diary entries",
85-
[Key.diaryReply]: "Reply",
86-
[Key.diaryTips]: "Only show the latest 30 diary entries",
87-
[Key.diaryMinutesAgo]: "minutes ago",
88-
[Key.diaryHoursAgo]: "hours ago",
89-
[Key.diaryDaysAgo]: "days ago",
81+
// Notes Page
82+
[Key.notes]: "Notes",
83+
[Key.notesSubtitle]: "Share life, anytime, anywhere",
84+
[Key.notesCount]: "notes entries",
85+
[Key.notesReply]: "Reply",
86+
[Key.notesMinutesAgo]: "minutes ago",
87+
[Key.notesHoursAgo]: "hours ago",
88+
[Key.notesDaysAgo]: "days ago",
9089
};

src/i18n/languages/zh_CN.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,12 @@ export const zh_CN: Translation = {
7373
[Key.atomCopied]: "Atom 链接已复制到剪贴板!",
7474
[Key.atomCopyFailed]: "复制失败,请手动复制链接",
7575

76-
// 短文页面
77-
[Key.diary]: "日记",
78-
[Key.diarySubtitle]: "随时随地,分享生活",
79-
[Key.diaryCount]: "条短文",
80-
[Key.diaryReply]: "回复",
81-
[Key.diaryTips]: "只展示最近30条日记",
82-
[Key.diaryMinutesAgo]: "分钟前",
83-
[Key.diaryHoursAgo]: "小时前",
84-
[Key.diaryDaysAgo]: "天前",
76+
// 随笔页面
77+
[Key.notes]: "随笔",
78+
[Key.notesSubtitle]: "随时随地,分享生活",
79+
[Key.notesCount]: "条随笔",
80+
[Key.notesReply]: "回复",
81+
[Key.notesMinutesAgo]: "分钟前",
82+
[Key.notesHoursAgo]: "小时前",
83+
[Key.notesDaysAgo]: "天前",
8584
};

0 commit comments

Comments
 (0)