From 6d39cee75e7ef7c5e06d1a745a32224e11d68c37 Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Fri, 23 Jan 2026 23:16:45 +0800 Subject: HALF WORK! --- www-2/content/posts/nspawn.md | 16 +- www-2/src/components/ArticlePreview.astro | 27 +-- www-2/src/components/ArticlePreviewList.astro | 35 ++++ www-2/src/content.config.ts | 4 +- www-2/src/layouts/ArticlePage.astro | 14 +- www-2/src/layouts/ListPage.astro | 23 +++ www-2/src/layouts/PageBase.astro | 242 +++++++++++++------------- www-2/src/pages/[...id].astro | 4 +- www-2/src/pages/index.astro | 19 +- www-2/src/pages/posts.astro | 11 ++ 10 files changed, 230 insertions(+), 165 deletions(-) create mode 100644 www-2/src/components/ArticlePreviewList.astro create mode 100644 www-2/src/layouts/ListPage.astro create mode 100644 www-2/src/pages/posts.astro (limited to 'www-2') diff --git a/www-2/content/posts/nspawn.md b/www-2/content/posts/nspawn.md index 866cf96..33501b4 100644 --- a/www-2/content/posts/nspawn.md +++ b/www-2/content/posts/nspawn.md @@ -66,21 +66,21 @@ its package manager. For Debian-based distributions, it's `debootstrap`. If your OS uses a different package manager ecosystem, the target distribution's one and its keyrings (which might reside somewhere else) have to be installed first. -```bash-session +```shellsession # pacman -S debootstrap debian-archive-keyring ubuntu-keyring ``` Regular directories work perfectly as root filesystems, but other directory-like things should work, too, such as `btrfs` subvolume. -```bash-session +```shellsession # btrfs subvolume create /var/lib/machines/[name] ``` Now, run `debootstrap` to create a minimal filesystem. Update the command with the target distribution's codename and one of its mirrors you select. -```bash-session +```shellsession # debootstrap --include=dbus,libpam-systemd,libnss-systemd [codename] \ /var/lib/machines/[name] [mirror] ``` @@ -125,14 +125,14 @@ further. Otherwise, you can use `systemd-nspawn` directly to enter the VM and run commands inside it. `--resolv-conf=bind-host` binds the host's `/etc/resolv.conf` file to make the network work. -```bash-session +```shellsession # systemd-nspawn --resolv-conf=bind-host -D /var/lib/machines/[name] ``` Now, inside the VM, you can do whatever you like. In my configuration, a correct user must be created manually. -```bash-session +```shellsession # apt install locales lsb-release sudo \ nano vim less man bash-completion curl wget \ build-essential git @@ -175,14 +175,14 @@ deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe The following command starts a new shell session for the specified user inside the VM, where you can run commands and perform tasks. -```bash-session +```shellsession # machinectl shell [user]@[name] ``` Another way is to use `login` command to enter the *login console*. From there, you can log in as a user to start a shell session. -```bash-session +```shellsession # machinectl login [name] ``` @@ -197,7 +197,7 @@ If the VM's filesystem is a `btrfs` subvolume, native `btrfs` snapshots can be used here. Before creating a snapshot, you should power off the VM to avoid archiving runtime files. -```bash-session +```shellsession # machinectl poweroff [name] # btrfs subvolume snapshot /var/lib/machines/[name] \ /var/lib/machines/btrfs-snapshots/[name]/[snapshot-name] diff --git a/www-2/src/components/ArticlePreview.astro b/www-2/src/components/ArticlePreview.astro index 3301ad2..bce8b50 100644 --- a/www-2/src/components/ArticlePreview.astro +++ b/www-2/src/components/ArticlePreview.astro @@ -1,22 +1,25 @@ --- -interface Props { - title: string; - date: string; - url: string; - content: string; +import type { CollectionEntry } from "astro:content"; + +export type Props = { + article: CollectionEntry<"articles">; headerElement?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "h7"; -} +}; -const { title, date, url, content, headerElement = "h2" } = Astro.props; +const { + article: { + id, + data: { title, date }, + }, + headerElement = "h2", +} = Astro.props; const H = headerElement; ---
- {date} - {title} -

- {content} -

+ {date.toLocaleString()} + {title} +

aaa

... Read more

diff --git a/www-2/src/components/ArticlePreviewList.astro b/www-2/src/components/ArticlePreviewList.astro new file mode 100644 index 0000000..abe54f2 --- /dev/null +++ b/www-2/src/components/ArticlePreviewList.astro @@ -0,0 +1,35 @@ +--- +import ArticlePreview, { + type Props as ArticlePreviewProps, +} from "./ArticlePreview.astro"; + +type Props = { + articles: ArticlePreviewProps["article"][]; +} & Omit; + +export type { Props }; + +const { articles, ...otherProps } = Astro.props; +--- + +{ + articles.length > 0 && ( + + ) +} + +{ + articles.slice(1).map((a) => ( + <> +
+ + + )) +} + + diff --git a/www-2/src/content.config.ts b/www-2/src/content.config.ts index f309aa5..f8a3aa1 100644 --- a/www-2/src/content.config.ts +++ b/www-2/src/content.config.ts @@ -2,7 +2,7 @@ import { defineCollection } from "astro:content"; import { glob } from "astro/loaders"; import { z } from "astro/zod"; -const blogs = defineCollection({ +const articles = defineCollection({ loader: glob({ pattern: "**/*.md", base: "./content" }), schema: z.object({ title: z.string(), @@ -14,4 +14,4 @@ const blogs = defineCollection({ }), }); -export const collections = { blogs }; +export const collections = { articles }; diff --git a/www-2/src/layouts/ArticlePage.astro b/www-2/src/layouts/ArticlePage.astro index b6ea5d0..669681e 100644 --- a/www-2/src/layouts/ArticlePage.astro +++ b/www-2/src/layouts/ArticlePage.astro @@ -1,23 +1,17 @@ --- +import type { CollectionEntry } from "astro:content"; + import PageBase from "./PageBase.astro"; import Nav from "../components/Nav.astro"; -interface Props { - id: string; - data: { - title: string; - date: Date; - lastmod?: Date; - }; -} +type Props = Pick, "id" | "data">; const { - id, data: { title, date, lastmod }, } = Astro.props; --- - +