From 78e3e234877cb10ca1088df31e831b36fa4a12c0 Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Fri, 23 Jan 2026 23:16:45 +0800 Subject: HALF WORK! --- www-2/src/assets/css/todos.css | 17 +++ www-2/src/assets/img/github.png | Bin 0 -> 6393 bytes www-2/src/components/ArticlePreview.astro | 68 +++++++++++ www-2/src/components/Friend.astro | 49 ++++++++ www-2/src/components/Nav.astro | 23 ++++ www-2/src/content.config.ts | 17 +++ www-2/src/layouts/ArticlePage.astro | 50 +++++++++ www-2/src/layouts/PageBase.astro | 181 ++++++++++++++++++++++++++++++ www-2/src/pages/[...id].astro | 18 +++ www-2/src/pages/index.astro | 124 ++++++++++++++++++++ 10 files changed, 547 insertions(+) create mode 100644 www-2/src/assets/css/todos.css create mode 100644 www-2/src/assets/img/github.png create mode 100644 www-2/src/components/ArticlePreview.astro create mode 100644 www-2/src/components/Friend.astro create mode 100644 www-2/src/components/Nav.astro create mode 100644 www-2/src/content.config.ts create mode 100644 www-2/src/layouts/ArticlePage.astro create mode 100644 www-2/src/layouts/PageBase.astro create mode 100644 www-2/src/pages/[...id].astro create mode 100644 www-2/src/pages/index.astro (limited to 'www-2/src') diff --git a/www-2/src/assets/css/todos.css b/www-2/src/assets/css/todos.css new file mode 100644 index 0000000..f9aa23b --- /dev/null +++ b/www-2/src/assets/css/todos.css @@ -0,0 +1,17 @@ +h3.todo { + &::before { + font-size: small; + } + + &.working::before { + content: "(working) "; + } + + &.done::before { + content: "(done) "; + } + + &.give-up::before { + content: "(give up) "; + } +} diff --git a/www-2/src/assets/img/github.png b/www-2/src/assets/img/github.png new file mode 100644 index 0000000..6cb3b70 Binary files /dev/null and b/www-2/src/assets/img/github.png differ diff --git a/www-2/src/components/ArticlePreview.astro b/www-2/src/components/ArticlePreview.astro new file mode 100644 index 0000000..3301ad2 --- /dev/null +++ b/www-2/src/components/ArticlePreview.astro @@ -0,0 +1,68 @@ +--- +interface Props { + title: string; + date: string; + url: string; + content: string; + headerElement?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "h7"; +} + +const { title, date, url, content, headerElement = "h2" } = Astro.props; +const H = headerElement; +--- + +
+ {date} + {title} +

+ {content} +

+

... Read more

+
+ + diff --git a/www-2/src/components/Friend.astro b/www-2/src/components/Friend.astro new file mode 100644 index 0000000..d0de0ab --- /dev/null +++ b/www-2/src/components/Friend.astro @@ -0,0 +1,49 @@ +--- +import githubIcon from "../assets/img/github.png"; + +interface Props { + name: string; + url?: string; + githubUrl: string; + avatarUrl: string; + tag?: string; +} + +const { name, githubUrl, url = githubUrl, avatarUrl, tag } = Astro.props; +--- + +
+ + {`Friend
{name}
+ + +
+ {tag && {tag}} +
+ + \ No newline at end of file diff --git a/www-2/src/components/Nav.astro b/www-2/src/components/Nav.astro new file mode 100644 index 0000000..f62a9dc --- /dev/null +++ b/www-2/src/components/Nav.astro @@ -0,0 +1,23 @@ +--- + +let path = Astro.url.pathname +if (path.startsWith("/")) { path = path.slice(1)} +if (path.endsWith("/")) { path = path.slice(0, -1)} +const segments = path.split("/").slice(0, -1); +const sections: {name: string; link: string;}[] = [] +let current = "/" +for (const segment of segments) { + current += segment + "/"; + sections.push({ + name: segment, + link: current + }) +} + +--- + diff --git a/www-2/src/content.config.ts b/www-2/src/content.config.ts new file mode 100644 index 0000000..f309aa5 --- /dev/null +++ b/www-2/src/content.config.ts @@ -0,0 +1,17 @@ +import { defineCollection } from "astro:content"; +import { glob } from "astro/loaders"; +import { z } from "astro/zod"; + +const blogs = defineCollection({ + loader: glob({ pattern: "**/*.md", base: "./content" }), + schema: z.object({ + title: z.string(), + description: z.string().optional(), + date: z.coerce.date(), + lastmod: z.coerce.date().optional(), + categories: z.string().optional(), + tags: z.array(z.string()).optional(), + }), +}); + +export const collections = { blogs }; diff --git a/www-2/src/layouts/ArticlePage.astro b/www-2/src/layouts/ArticlePage.astro new file mode 100644 index 0000000..b6ea5d0 --- /dev/null +++ b/www-2/src/layouts/ArticlePage.astro @@ -0,0 +1,50 @@ +--- +import PageBase from "./PageBase.astro"; +import Nav from "../components/Nav.astro"; + +interface Props { + id: string; + data: { + title: string; + date: Date; + lastmod?: Date; + }; +} + +const { + id, + data: { title, date, lastmod }, +} = Astro.props; +--- + + +