hd-garden 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/garden-interactive-chart/SKILL.md +5 -5
- package/Makefile +2 -3
- package/app/a2/[slug]/page.tsx +0 -1
- package/app/a2/page.tsx +1 -1
- package/app/about/page.tsx +8 -12
- package/app/admin/page.tsx +2 -2
- package/app/blog/[...path]/page.tsx +4 -14
- package/app/blog/page.tsx +6 -3
- package/app/columns/[column]/[...path]/page.tsx +4 -9
- package/app/columns/page.tsx +2 -2
- package/app/components/AdminDashboard.tsx +3 -3
- package/app/components/ArticleMeasure.tsx +114 -42
- package/app/components/ArticleReferences.tsx +31 -31
- package/app/components/ArticleTags.tsx +17 -0
- package/app/components/BlogArchive.tsx +94 -50
- package/app/components/ContentEmptyState.tsx +6 -6
- package/app/components/CoverImage.tsx +34 -0
- package/app/components/GardenAdminGuide.tsx +1 -1
- package/app/components/GardenContentGuide.tsx +1 -2
- package/app/components/GardenMediaGuide.tsx +3 -3
- package/app/components/GithubProfile.tsx +1 -1
- package/app/components/LinkCardRefresh.tsx +44 -0
- package/app/components/MarkdownArticle.tsx +87 -19
- package/app/components/MarkdownImage.tsx +4 -2
- package/app/components/SiteFooter.tsx +5 -5
- package/app/components/SiteHeader.tsx +105 -33
- package/app/components/TagRedirect.tsx +17 -0
- package/app/garden/page.tsx +6 -6
- package/app/garden-modules.d.ts +17 -2
- package/app/globals.css +92 -136
- package/app/layout.tsx +1 -7
- package/app/lib/a2-meta.ts +10 -0
- package/app/lib/a2-preview.ts +0 -2
- package/app/lib/archive.ts +43 -0
- package/app/lib/content.ts +12 -43
- package/app/lib/fallback-site-config.ts +15 -15
- package/app/lib/generated-content.ts +58 -47
- package/app/lib/heading-number.ts +9 -0
- package/app/lib/remark-link-card.mjs +83 -0
- package/app/lib/tag-filter.ts +151 -0
- package/app/not-found.tsx +13 -0
- package/app/page.tsx +12 -29
- package/app/rss.xml/route.ts +2 -1
- package/app/styles/a2.css +159 -27
- package/app/styles/shell.css +54 -59
- package/app/styles/tokens.css +35 -22
- package/app/tags/page.tsx +20 -9
- package/bin/garden.mjs +6 -0
- package/package.json +1 -1
- package/scripts/build-content.mjs +50 -9
- package/scripts/check-post.mjs +0 -3
- package/scripts/cover-images.mjs +69 -0
- package/scripts/link-assets.mjs +271 -0
- package/scripts/link-meta-core.mjs +321 -0
- package/scripts/new-post.mjs +1 -3
- package/site.config.yaml +15 -15
- package/templates/site/Makefile +2 -3
- package/templates/site/site.config.yaml +15 -15
- package/ui/core/transform.mjs +4 -3
- package/ui/garden/card-refresh.mjs +92 -0
- package/ui/garden/check.mjs +2 -4
- package/ui/garden/enhance.mjs +57 -0
- package/ui/garden/markdown-links.mjs +84 -0
- package/ui/garden/references.mjs +21 -0
- package/ui/garden/search-full.mjs +131 -0
- package/ui/garden/search-index.mjs +102 -0
- package/ui/garden/search-match.mjs +96 -0
- package/ui/garden/title.mjs +5 -8
- package/ui/host.mjs +13 -13
- package/ui/preview/dist/garden-ui.css +11 -11
- package/ui/preview/dist/garden-ui.esm.js +8 -8
- package/ui/preview/dist/garden-ui.iife.js +8 -8
- package/ui/react/components/media.tsx +2 -2
- package/ui/react/ui.css +11 -11
- package/worker/og/README.md +59 -0
- package/worker/og/handler.mjs +147 -0
- package/worker/og/index.mjs +61 -0
- package/worker/og/wrangler.toml +18 -0
- package/app/components/TagIndex.tsx +0 -97
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { toString } from "mdast-util-to-string";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `[text](url){card}` asks for a link card.
|
|
5
|
+
*
|
|
6
|
+
* - The marker only counts written straight after the link's `)`. Inside code
|
|
7
|
+
* it is plain text and stays.
|
|
8
|
+
* - A paragraph that is nothing but the marked link becomes the card itself,
|
|
9
|
+
* in the same spot; the inline link is not kept.
|
|
10
|
+
* - Otherwise the link stays in the sentence and its card follows the
|
|
11
|
+
* paragraph (inside the same list item or quote).
|
|
12
|
+
*
|
|
13
|
+
* Cards are `garden-linkcard` elements carrying `data-url`, `data-text` and,
|
|
14
|
+
* for the standalone form, `data-standalone`.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const MARKER = "{card}";
|
|
18
|
+
const isHttp = (url) => /^https?:\/\//iu.test(url ?? "");
|
|
19
|
+
|
|
20
|
+
function writtenAsLink(node, source) {
|
|
21
|
+
if (!source || node.position?.end?.offset === undefined) return true;
|
|
22
|
+
return source[node.position.end.offset - 1] === ")";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function cardNode(link, standalone) {
|
|
26
|
+
const properties = { dataUrl: link.url, dataText: toString(link).trim() };
|
|
27
|
+
if (standalone) properties.dataStandalone = "true";
|
|
28
|
+
return { type: "linkCard", data: { hName: "garden-linkcard", hProperties: properties }, children: [] };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const meaningful = (children) =>
|
|
32
|
+
children.filter((child) => !(child.type === "text" && !child.value.trim()) && child.type !== "break");
|
|
33
|
+
|
|
34
|
+
/** Take the markers out of one parent's inline children; return the marked links. */
|
|
35
|
+
function takeMarkers(parent, source) {
|
|
36
|
+
const marked = [];
|
|
37
|
+
const children = parent.children ?? [];
|
|
38
|
+
for (let index = 0; index < children.length - 1; index += 1) {
|
|
39
|
+
const link = children[index];
|
|
40
|
+
const next = children[index + 1];
|
|
41
|
+
if (link.type !== "link" || next.type !== "text" || !next.value.startsWith(MARKER)) continue;
|
|
42
|
+
if (!isHttp(link.url) || !writtenAsLink(link, source)) continue;
|
|
43
|
+
next.value = next.value.slice(MARKER.length);
|
|
44
|
+
marked.push(link);
|
|
45
|
+
}
|
|
46
|
+
parent.children = children.filter((child) => !(child.type === "text" && child.value === ""));
|
|
47
|
+
return marked;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function walk(parent, source) {
|
|
51
|
+
const children = parent.children ?? [];
|
|
52
|
+
for (let index = 0; index < children.length; index += 1) {
|
|
53
|
+
const node = children[index];
|
|
54
|
+
if (node.type === "code" || node.type === "inlineCode" || node.type === "html") continue;
|
|
55
|
+
if (node.type !== "paragraph") {
|
|
56
|
+
if (node.children) {
|
|
57
|
+
// Headings, table cells and the like: drop the marker, no card.
|
|
58
|
+
if (node.type === "heading" || node.type === "tableCell") takeMarkers(node, source);
|
|
59
|
+
walk(node, source);
|
|
60
|
+
}
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
// Links nested in emphasis count too.
|
|
64
|
+
const marked = takeMarkers(node, source);
|
|
65
|
+
for (const child of node.children) if (child.children && child.type !== "link") marked.push(...takeMarkers(child, source));
|
|
66
|
+
if (!marked.length) continue;
|
|
67
|
+
const rest = meaningful(node.children);
|
|
68
|
+
if (marked.length === 1 && rest.length === 1 && rest[0] === marked[0]) {
|
|
69
|
+
children[index] = cardNode(marked[0], true);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const cards = marked.map((link) => cardNode(link, false));
|
|
73
|
+
children.splice(index + 1, 0, ...cards);
|
|
74
|
+
index += cards.length;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function remarkLinkCard() {
|
|
79
|
+
return (tree, file) => {
|
|
80
|
+
const source = typeof file?.value === "string" ? file.value : String(file?.value ?? "");
|
|
81
|
+
walk(tree, source);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tag filtering for the article list. Pure functions only, so the list page
|
|
3
|
+
* and the tests share one implementation.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type Tagged = { tags?: string[] };
|
|
7
|
+
|
|
8
|
+
export type TagOption = {
|
|
9
|
+
tag: string;
|
|
10
|
+
/** Posts carrying this tag. */
|
|
11
|
+
total: number;
|
|
12
|
+
/** Posts left if this tag were added to the selection (the current result when already selected). */
|
|
13
|
+
next: number;
|
|
14
|
+
selected: boolean;
|
|
15
|
+
/** Adding it would leave nothing. Selected tags are never disabled. */
|
|
16
|
+
disabled: boolean;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const TAG_PARAM = "t";
|
|
20
|
+
export const DEFAULT_VISIBLE_TAGS = 14;
|
|
21
|
+
|
|
22
|
+
const byCount = (left: [string, number], right: [string, number]) =>
|
|
23
|
+
right[1] - left[1] || left[0].localeCompare(right[0], "zh");
|
|
24
|
+
|
|
25
|
+
/** Tags match regardless of case: `Rust`, `rust` and `RUST` are one tag. */
|
|
26
|
+
export const tagKey = (tag: string) => tag.trim().toLocaleLowerCase();
|
|
27
|
+
|
|
28
|
+
const postKeys = (post: Tagged) => new Set((post.tags ?? []).map(tagKey).filter(Boolean));
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Every tag with its post count, most used first. Spellings that differ only
|
|
32
|
+
* in case count as one tag, shown in its most common spelling.
|
|
33
|
+
*/
|
|
34
|
+
export function tagCounts(posts: readonly Tagged[]): [string, number][] {
|
|
35
|
+
const counts = new Map<string, number>();
|
|
36
|
+
const spellings = new Map<string, Map<string, number>>();
|
|
37
|
+
for (const post of posts) {
|
|
38
|
+
const seen = new Set<string>();
|
|
39
|
+
for (const raw of post.tags ?? []) {
|
|
40
|
+
const tag = raw.trim();
|
|
41
|
+
const key = tagKey(tag);
|
|
42
|
+
if (!key) continue;
|
|
43
|
+
const forms = spellings.get(key) ?? new Map<string, number>();
|
|
44
|
+
forms.set(tag, (forms.get(tag) ?? 0) + 1);
|
|
45
|
+
spellings.set(key, forms);
|
|
46
|
+
if (seen.has(key)) continue;
|
|
47
|
+
seen.add(key);
|
|
48
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return [...counts.entries()]
|
|
52
|
+
.map(([key, count]): [string, number] => {
|
|
53
|
+
// Map keeps insertion order, so ties go to the first spelling seen.
|
|
54
|
+
const [label] = [...(spellings.get(key) ?? new Map([[key, 0]])).entries()].reduce((best, form) => (form[1] > best[1] ? form : best));
|
|
55
|
+
return [label, count];
|
|
56
|
+
})
|
|
57
|
+
.sort(byCount);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Selected tags from the repeated URL param, trimmed and de-duplicated (ignoring case), in URL order. */
|
|
61
|
+
export function selectedTags(values: readonly string[]): string[] {
|
|
62
|
+
const seen = new Map<string, string>();
|
|
63
|
+
for (const value of values) {
|
|
64
|
+
const tag = value.trim();
|
|
65
|
+
const key = tagKey(tag);
|
|
66
|
+
if (key && !seen.has(key)) seen.set(key, tag);
|
|
67
|
+
}
|
|
68
|
+
return [...seen.values()];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Selected tags written the way the posts write them (`?t=Rust` becomes `rust`); unknown tags stay as given. */
|
|
72
|
+
export function canonicalTags(posts: readonly Tagged[], selected: readonly string[]): string[] {
|
|
73
|
+
const labels = new Map(tagCounts(posts).map(([tag]) => [tagKey(tag), tag]));
|
|
74
|
+
return selected.map((tag) => labels.get(tagKey(tag)) ?? tag);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const hasAll = (post: Tagged, tags: readonly string[]) => {
|
|
78
|
+
const own = postKeys(post);
|
|
79
|
+
return tags.every((tag) => own.has(tagKey(tag)));
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/** Posts carrying every selected tag (intersection). No selection keeps everything. */
|
|
83
|
+
export function filterByTags<T extends Tagged>(posts: readonly T[], selected: readonly string[]): T[] {
|
|
84
|
+
return selected.length ? posts.filter((post) => hasAll(post, selected)) : posts.slice();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** One option per known tag plus any selected tag the posts do not use. */
|
|
88
|
+
export function tagOptions(posts: readonly Tagged[], selected: readonly string[]): TagOption[] {
|
|
89
|
+
const current = filterByTags(posts, selected);
|
|
90
|
+
const chosen = new Set(selected.map(tagKey));
|
|
91
|
+
const options = tagCounts(posts).map(([tag, total]) => {
|
|
92
|
+
const key = tagKey(tag);
|
|
93
|
+
const isSelected = chosen.has(key);
|
|
94
|
+
const next = isSelected ? current.length : current.filter((post) => postKeys(post).has(key)).length;
|
|
95
|
+
return { tag, total, next, selected: isSelected, disabled: !isSelected && next === 0 };
|
|
96
|
+
});
|
|
97
|
+
for (const tag of selected) {
|
|
98
|
+
if (!options.some((option) => tagKey(option.tag) === tagKey(tag))) {
|
|
99
|
+
options.push({ tag, total: 0, next: 0, selected: true, disabled: false });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return options;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Tags shown before 「全部标签」 is expanded.
|
|
107
|
+
*
|
|
108
|
+
* - No selection: the top tags by count.
|
|
109
|
+
* - With a selection: the selected tags, then the tags that still have results,
|
|
110
|
+
* most remaining posts first, up to the same limit. Tags that would leave
|
|
111
|
+
* nothing come last and only when expanded.
|
|
112
|
+
*/
|
|
113
|
+
export function visibleTagOptions(options: readonly TagOption[], expanded: boolean, limit = DEFAULT_VISIBLE_TAGS) {
|
|
114
|
+
const anySelected = options.some((option) => option.selected);
|
|
115
|
+
if (!anySelected) {
|
|
116
|
+
if (expanded) return { shown: options.slice(), hidden: 0 };
|
|
117
|
+
const shown = options.slice(0, limit);
|
|
118
|
+
return { shown, hidden: options.length - shown.length };
|
|
119
|
+
}
|
|
120
|
+
const selected = options.filter((option) => option.selected);
|
|
121
|
+
// Array.prototype.sort is stable, so equal counts keep the by-total order.
|
|
122
|
+
const open = options
|
|
123
|
+
.filter((option) => !option.selected && !option.disabled)
|
|
124
|
+
.sort((left, right) => right.next - left.next);
|
|
125
|
+
const closed = options.filter((option) => !option.selected && option.disabled);
|
|
126
|
+
const ordered = [...selected, ...open, ...closed];
|
|
127
|
+
if (expanded) return { shown: ordered, hidden: 0 };
|
|
128
|
+
const shown = [...selected, ...open.slice(0, Math.max(0, limit - selected.length))];
|
|
129
|
+
return { shown, hidden: options.length - shown.length };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Add the tag if absent, remove it if present (in any spelling). */
|
|
133
|
+
export function toggleTag(selected: readonly string[], tag: string): string[] {
|
|
134
|
+
const key = tagKey(tag);
|
|
135
|
+
return selected.some((item) => tagKey(item) === key)
|
|
136
|
+
? selected.filter((item) => tagKey(item) !== key)
|
|
137
|
+
: [...selected, tag];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** `/blog?t=A&t=B`, or `/blog` with no selection. */
|
|
141
|
+
export function tagFilterHref(selected: readonly string[], pathname = "/blog") {
|
|
142
|
+
const params = new URLSearchParams();
|
|
143
|
+
for (const tag of selected) params.append(TAG_PARAM, tag);
|
|
144
|
+
const query = params.toString();
|
|
145
|
+
return query ? `${pathname}?${query}` : pathname;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** 「共 N 篇」, or 「2 个标签,共 5 篇」 with a selection. */
|
|
149
|
+
export function tagSummary(selectedCount: number, resultCount: number) {
|
|
150
|
+
return selectedCount ? `${selectedCount} 个标签,共 ${resultCount} 篇` : `共 ${resultCount} 篇`;
|
|
151
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Link from "next/link";
|
|
2
|
+
|
|
3
|
+
export default function NotFound() {
|
|
4
|
+
return (
|
|
5
|
+
<main className="page-shell">
|
|
6
|
+
<header className="sh-head">
|
|
7
|
+
<h1>找不到这一页</h1>
|
|
8
|
+
<p className="sh-deck">地址可能写错了,或者这篇已经不在了。</p>
|
|
9
|
+
</header>
|
|
10
|
+
<p><Link href="/">返回首页</Link></p>
|
|
11
|
+
</main>
|
|
12
|
+
);
|
|
13
|
+
}
|
package/app/page.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Link from "next/link";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { CoverImage } from "./components/CoverImage";
|
|
3
|
+
import { homeListDate } from "./lib/a2-meta";
|
|
4
|
+
import { columns, formatDate, postHref, posts } from "./lib/content";
|
|
5
5
|
import { githubUrl, siteConfig } from "./site.config";
|
|
6
6
|
|
|
7
7
|
export const metadata = {
|
|
@@ -21,10 +21,10 @@ function day(value: string) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export default function Home() {
|
|
24
|
-
const
|
|
25
|
-
const feature =
|
|
24
|
+
const recentAll = [...posts].sort((left, right) => Date.parse(right.date) - Date.parse(left.date));
|
|
25
|
+
const feature = recentAll[0];
|
|
26
|
+
const recent = recentAll.filter((post) => post.path !== feature?.path);
|
|
26
27
|
const pinned = posts.filter((post) => post.pinned);
|
|
27
|
-
const thoughts = getPublishedThoughts();
|
|
28
28
|
const series = Array.from(
|
|
29
29
|
columns.reduce((result, entry) => {
|
|
30
30
|
const existing = result.get(entry.column ?? "");
|
|
@@ -50,15 +50,13 @@ export default function Home() {
|
|
|
50
50
|
<article className="sh-feature" aria-labelledby="ft">
|
|
51
51
|
{feature.cover ? (
|
|
52
52
|
<div className="cover">
|
|
53
|
-
{
|
|
54
|
-
<img src={feature.cover} alt="" />
|
|
53
|
+
<CoverImage src={feature.cover} image={feature.coverImage} alt="" sizes="(max-width: 700px) calc(100vw - 40px), 604px" priority />
|
|
55
54
|
</div>
|
|
56
55
|
) : null}
|
|
57
56
|
<div>
|
|
58
57
|
<p className="kicker">
|
|
59
58
|
<span>最新文章</span>
|
|
60
|
-
<time className="num" dateTime={day(feature.date)}>{
|
|
61
|
-
{feature.topic ? <span>{feature.topic}</span> : null}
|
|
59
|
+
<time className="num" dateTime={day(feature.date)}>{formatDate(feature.date)}</time>
|
|
62
60
|
</p>
|
|
63
61
|
<h2 id="ft"><Link href={postHref(feature)}>{feature.title}</Link></h2>
|
|
64
62
|
{feature.description ? <p>{feature.description}</p> : null}
|
|
@@ -76,12 +74,11 @@ export default function Home() {
|
|
|
76
74
|
<Link className="sh-more" href="/blog">全部 {posts.length} 篇</Link>
|
|
77
75
|
</div>
|
|
78
76
|
<ol className="sh-rows">
|
|
79
|
-
{recent.slice(0,
|
|
77
|
+
{recent.slice(0, 6).map((post) => (
|
|
80
78
|
<li className="sh-row" key={post.path}>
|
|
81
|
-
<time className="num" dateTime={day(post.date)}>{
|
|
79
|
+
<time className="num" dateTime={day(post.date)}>{homeListDate(post.date)}</time>
|
|
82
80
|
<h3><Link href={postHref(post)}>{post.title}</Link></h3>
|
|
83
81
|
{post.description ? <p>{post.description}</p> : null}
|
|
84
|
-
{post.topic ? <Link className="cat" href={`/blog?topic=${encodeURIComponent(post.topic)}`}>{post.topic}</Link> : null}
|
|
85
82
|
</li>
|
|
86
83
|
))}
|
|
87
84
|
</ol>
|
|
@@ -93,7 +90,7 @@ export default function Home() {
|
|
|
93
90
|
{pinned.map((post) => (
|
|
94
91
|
<li key={post.path}>
|
|
95
92
|
<Link href={postHref(post)}>{post.title}</Link>
|
|
96
|
-
<span><time className="num" dateTime={day(post.date)}>{
|
|
93
|
+
<span><time className="num" dateTime={day(post.date)}>{formatDate(post.date)}</time></span>
|
|
97
94
|
</li>
|
|
98
95
|
))}
|
|
99
96
|
</ul>
|
|
@@ -115,7 +112,7 @@ export default function Home() {
|
|
|
115
112
|
<div className="cover" style={{ background: "var(--well)" }}>
|
|
116
113
|
{first.columnCover ? (
|
|
117
114
|
// eslint-disable-next-line @next/next/no-img-element
|
|
118
|
-
<img src={first.columnCover} alt={first.columnCoverAlt ?? ""} />
|
|
115
|
+
<img src={first.columnCover} alt={first.columnCoverAlt ?? ""} loading="lazy" decoding="async" />
|
|
119
116
|
) : null}
|
|
120
117
|
</div>
|
|
121
118
|
<div className="body">
|
|
@@ -129,20 +126,6 @@ export default function Home() {
|
|
|
129
126
|
</div>
|
|
130
127
|
</section>
|
|
131
128
|
) : null}
|
|
132
|
-
|
|
133
|
-
{thoughts.length > 0 ? (
|
|
134
|
-
<section className="sh-section" aria-labelledby="h-thoughts">
|
|
135
|
-
<div className="sh-sec-head">
|
|
136
|
-
<h2 id="h-thoughts">最近随想</h2>
|
|
137
|
-
<Link className="sh-more" href="/thoughts">全部随想</Link>
|
|
138
|
-
</div>
|
|
139
|
-
<div className="home-thought-list">
|
|
140
|
-
{thoughts.slice(0, 5).map((thought) => (
|
|
141
|
-
<ThoughtCard key={thought.slug} thought={thought} />
|
|
142
|
-
))}
|
|
143
|
-
</div>
|
|
144
|
-
</section>
|
|
145
|
-
) : null}
|
|
146
129
|
</main>
|
|
147
130
|
);
|
|
148
131
|
}
|
package/app/rss.xml/route.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { columnHref, columns, postHref, posts } from "../lib/content";
|
|
|
3
3
|
import { getPublishedThoughts } from "../lib/public-thoughts";
|
|
4
4
|
import { configuredSiteUrl, siteDescription, siteName } from "../lib/site";
|
|
5
5
|
import { contentForFeed } from "../../ui/core/transform.mjs";
|
|
6
|
+
import { stripCardMarkers } from "../../ui/garden/markdown-links.mjs";
|
|
6
7
|
|
|
7
8
|
const escapeXml = (value: string) =>
|
|
8
9
|
value
|
|
@@ -25,7 +26,7 @@ export async function GET() {
|
|
|
25
26
|
})),
|
|
26
27
|
...thoughts.map((thought) => ({
|
|
27
28
|
...thought,
|
|
28
|
-
description: thought.content.replace(/\s+/gu, " ").slice(0, 180),
|
|
29
|
+
description: stripCardMarkers(thought.content).replace(/\s+/gu, " ").slice(0, 180),
|
|
29
30
|
path: `/thoughts/${thought.slug}`,
|
|
30
31
|
})),
|
|
31
32
|
].sort((a, b) => Date.parse(b.date) - Date.parse(a.date));
|
package/app/styles/a2.css
CHANGED
|
@@ -105,7 +105,8 @@ body {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
.post-reading-page {
|
|
108
|
-
|
|
108
|
+
/* rail + gap + 740px column + gap + rail, plus side padding */
|
|
109
|
+
width: min(1360px, 100%);
|
|
109
110
|
padding-right: 32px;
|
|
110
111
|
padding-left: 32px;
|
|
111
112
|
}
|
|
@@ -191,6 +192,55 @@ body {
|
|
|
191
192
|
font-size: var(--fs-meta);
|
|
192
193
|
}
|
|
193
194
|
|
|
195
|
+
.article-tagrow {
|
|
196
|
+
display: flex;
|
|
197
|
+
flex-wrap: wrap;
|
|
198
|
+
justify-content: center;
|
|
199
|
+
gap: 8px;
|
|
200
|
+
margin: 14px 0 0;
|
|
201
|
+
padding: 0;
|
|
202
|
+
list-style: none;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.article-tagrow li {
|
|
206
|
+
margin: 0;
|
|
207
|
+
padding: 0;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.article-tagrow .tag-chip {
|
|
211
|
+
position: relative;
|
|
212
|
+
display: inline-block;
|
|
213
|
+
padding: 2px 10px;
|
|
214
|
+
border-radius: 999px;
|
|
215
|
+
background: var(--chip);
|
|
216
|
+
color: var(--soft);
|
|
217
|
+
font-size: var(--fs-meta);
|
|
218
|
+
line-height: 1.6;
|
|
219
|
+
text-decoration: none;
|
|
220
|
+
white-space: nowrap;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/* 44px tall hit area without enlarging the chip */
|
|
224
|
+
.article-tagrow .tag-chip::after {
|
|
225
|
+
content: "";
|
|
226
|
+
position: absolute;
|
|
227
|
+
left: 0;
|
|
228
|
+
right: 0;
|
|
229
|
+
top: 50%;
|
|
230
|
+
height: 44px;
|
|
231
|
+
transform: translateY(-50%);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.article-tagrow .tag-chip:hover {
|
|
235
|
+
background: var(--chip-hover);
|
|
236
|
+
color: var(--ink);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.article-tagrow .tag-chip:focus-visible {
|
|
240
|
+
outline: 2px solid var(--blue);
|
|
241
|
+
outline-offset: 2px;
|
|
242
|
+
}
|
|
243
|
+
|
|
194
244
|
.cover-card.cover-img,
|
|
195
245
|
.article-hero.article-cover {
|
|
196
246
|
width: 100%;
|
|
@@ -262,7 +312,7 @@ body {
|
|
|
262
312
|
|
|
263
313
|
.post-reading-page .e-content,
|
|
264
314
|
.column-reading-page .e-content {
|
|
265
|
-
--qa-bar: #
|
|
315
|
+
--qa-bar: #e8e6dc;
|
|
266
316
|
--qa-text: #737069;
|
|
267
317
|
}
|
|
268
318
|
|
|
@@ -277,7 +327,7 @@ html[data-theme="dark"] .column-reading-page .e-content {
|
|
|
277
327
|
.lead.quote-plain {
|
|
278
328
|
margin: 0 0 32px;
|
|
279
329
|
padding: 2px 0 2px 24px;
|
|
280
|
-
border-left: 3px solid var(--qa-bar, #
|
|
330
|
+
border-left: 3px solid var(--qa-bar, #e8e6dc);
|
|
281
331
|
border-radius: 0;
|
|
282
332
|
background: none;
|
|
283
333
|
color: var(--qa-text, #737069);
|
|
@@ -331,7 +381,13 @@ html[data-theme="dark"] .column-reading-page .e-content {
|
|
|
331
381
|
text-decoration: underline;
|
|
332
382
|
text-decoration-thickness: 1px;
|
|
333
383
|
text-underline-offset: 4px;
|
|
334
|
-
text-decoration-color:
|
|
384
|
+
text-decoration-color: color-mix(in srgb, var(--ink) 35%, transparent);
|
|
385
|
+
transition: text-decoration-color 0.15s ease;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
.markdown-body a:hover {
|
|
389
|
+
text-decoration-color: var(--ink);
|
|
390
|
+
text-decoration-thickness: 2px;
|
|
335
391
|
}
|
|
336
392
|
|
|
337
393
|
.markdown-body a.ext {
|
|
@@ -349,6 +405,35 @@ html[data-theme="dark"] .markdown-body a.ext {
|
|
|
349
405
|
.markdown-body a.ext:hover {
|
|
350
406
|
text-decoration-style: solid;
|
|
351
407
|
text-decoration-color: var(--ink);
|
|
408
|
+
text-decoration-thickness: 2px;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/* Site favicon before an external link, downloaded at build time. */
|
|
412
|
+
.markdown-body a.ext img.fav {
|
|
413
|
+
display: inline-block;
|
|
414
|
+
width: 14px;
|
|
415
|
+
height: 14px;
|
|
416
|
+
margin: 0 5px 0 0;
|
|
417
|
+
border-radius: 3px;
|
|
418
|
+
vertical-align: -2px;
|
|
419
|
+
object-fit: contain;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
.markdown-body a.ext .fav-keep {
|
|
423
|
+
white-space: nowrap;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/* Many icons are black on transparent; give them a light backing in dark mode. */
|
|
427
|
+
html[data-theme="dark"] .markdown-body img.fav {
|
|
428
|
+
padding: 1px;
|
|
429
|
+
box-sizing: border-box;
|
|
430
|
+
background: #f5f4ed;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
.markdown-body .table-wrap a.ext img.fav,
|
|
434
|
+
.markdown-body h2 a.ext img.fav,
|
|
435
|
+
.markdown-body h3 a.ext img.fav {
|
|
436
|
+
display: none;
|
|
352
437
|
}
|
|
353
438
|
|
|
354
439
|
.markdown-body :not(pre) > code {
|
|
@@ -381,15 +466,15 @@ html[data-theme="dark"] .markdown-body a.ext {
|
|
|
381
466
|
}
|
|
382
467
|
|
|
383
468
|
.markdown-body.prose {
|
|
384
|
-
--al-note: #
|
|
385
|
-
--al-note-bg: #
|
|
386
|
-
--al-note-line: rgba(
|
|
469
|
+
--al-note: #30302e;
|
|
470
|
+
--al-note-bg: #f0eee6;
|
|
471
|
+
--al-note-line: rgba(20, 20, 19, 0.18);
|
|
387
472
|
--al-tip: #2d6a3e;
|
|
388
473
|
--al-tip-bg: #edf5ef;
|
|
389
474
|
--al-tip-line: rgba(45, 106, 62, 0.22);
|
|
390
|
-
--al-important: #
|
|
391
|
-
--al-important-bg: #
|
|
392
|
-
--al-important-line: rgba(
|
|
475
|
+
--al-important: #30302e;
|
|
476
|
+
--al-important-bg: #f0eee6;
|
|
477
|
+
--al-important-line: rgba(20, 20, 19, 0.14);
|
|
393
478
|
--al-warning: #8a5300;
|
|
394
479
|
--al-warning-bg: #fbf3e5;
|
|
395
480
|
--al-warning-line: rgba(176, 108, 0, 0.26);
|
|
@@ -402,15 +487,15 @@ html[data-theme="dark"] .markdown-body a.ext {
|
|
|
402
487
|
:root[data-theme="dark"] .prose,
|
|
403
488
|
html[data-theme="dark"] .markdown-body.prose,
|
|
404
489
|
html[data-theme="dark"] .prose {
|
|
405
|
-
--al-note: #
|
|
406
|
-
--al-note-bg: rgba(
|
|
407
|
-
--al-note-line: rgba(
|
|
490
|
+
--al-note: #eeece7;
|
|
491
|
+
--al-note-bg: rgba(238, 236, 231, 0.06);
|
|
492
|
+
--al-note-line: rgba(238, 236, 231, 0.22);
|
|
408
493
|
--al-tip: #8fcb9f;
|
|
409
494
|
--al-tip-bg: rgba(143, 203, 159, 0.08);
|
|
410
495
|
--al-tip-line: rgba(143, 203, 159, 0.26);
|
|
411
|
-
--al-important: #
|
|
412
|
-
--al-important-bg:
|
|
413
|
-
--al-important-line: rgba(
|
|
496
|
+
--al-important: #eeece7;
|
|
497
|
+
--al-important-bg: #30302e;
|
|
498
|
+
--al-important-line: rgba(238, 236, 231, 0.14);
|
|
414
499
|
--al-warning: #e6b566;
|
|
415
500
|
--al-warning-bg: rgba(230, 181, 102, 0.08);
|
|
416
501
|
--al-warning-line: rgba(230, 181, 102, 0.28);
|
|
@@ -450,10 +535,17 @@ html[data-theme="dark"] .prose {
|
|
|
450
535
|
--al-line: var(--al-tip-line);
|
|
451
536
|
}
|
|
452
537
|
|
|
538
|
+
/* IMPORTANT reads in ink: a dark bar on the left and a bold title. */
|
|
453
539
|
.markdown-body .markdown-alert-important {
|
|
454
540
|
--al: var(--al-important);
|
|
455
541
|
--al-bg: var(--al-important-bg);
|
|
456
542
|
--al-line: var(--al-important-line);
|
|
543
|
+
border-left: 3px solid var(--al-important);
|
|
544
|
+
padding-left: 18px;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
.markdown-body .markdown-alert-important .markdown-alert-title {
|
|
548
|
+
font-weight: 700;
|
|
457
549
|
}
|
|
458
550
|
|
|
459
551
|
.markdown-body .markdown-alert-warning {
|
|
@@ -578,7 +670,9 @@ html[data-theme="dark"] .markdown-body .markdown-alert code {
|
|
|
578
670
|
}
|
|
579
671
|
|
|
580
672
|
.markdown-body .fig-card img {
|
|
581
|
-
width:
|
|
673
|
+
width: auto;
|
|
674
|
+
max-width: 100%;
|
|
675
|
+
margin: 0 auto;
|
|
582
676
|
border-radius: 8px;
|
|
583
677
|
}
|
|
584
678
|
|
|
@@ -611,6 +705,7 @@ html[data-theme="dark"] .markdown-body .markdown-alert code {
|
|
|
611
705
|
}
|
|
612
706
|
|
|
613
707
|
.table-wrap table {
|
|
708
|
+
margin: 0;
|
|
614
709
|
border-collapse: collapse;
|
|
615
710
|
width: 100%;
|
|
616
711
|
font-size: var(--fs-small);
|
|
@@ -620,6 +715,8 @@ html[data-theme="dark"] .markdown-body .markdown-alert code {
|
|
|
620
715
|
.table-wrap th,
|
|
621
716
|
.table-wrap td {
|
|
622
717
|
padding: 10px 14px;
|
|
718
|
+
overflow-wrap: normal;
|
|
719
|
+
word-break: normal;
|
|
623
720
|
text-align: left;
|
|
624
721
|
vertical-align: top;
|
|
625
722
|
border-bottom: 1px solid var(--rule);
|
|
@@ -651,10 +748,27 @@ html[data-theme="dark"] .markdown-body .markdown-alert code {
|
|
|
651
748
|
color: var(--grey);
|
|
652
749
|
}
|
|
653
750
|
|
|
751
|
+
.toc .toc-item-row {
|
|
752
|
+
position: relative;
|
|
753
|
+
padding-left: 10px;
|
|
754
|
+
}
|
|
755
|
+
|
|
654
756
|
.toc a[aria-current="location"],
|
|
655
757
|
.toc li.active > .toc-item-row > a {
|
|
656
758
|
color: var(--ink);
|
|
657
|
-
font-weight:
|
|
759
|
+
font-weight: 600;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
/* The current section carries an ink bar, so it reads without colour. */
|
|
763
|
+
.toc li.active > .toc-item-row::before {
|
|
764
|
+
content: "";
|
|
765
|
+
position: absolute;
|
|
766
|
+
left: 0;
|
|
767
|
+
top: 0.2em;
|
|
768
|
+
bottom: 0.2em;
|
|
769
|
+
width: 2px;
|
|
770
|
+
border-radius: 1px;
|
|
771
|
+
background: var(--ink);
|
|
658
772
|
}
|
|
659
773
|
|
|
660
774
|
@media (min-width: 1200px) {
|
|
@@ -670,6 +784,7 @@ html[data-theme="dark"] .markdown-body .markdown-alert code {
|
|
|
670
784
|
|
|
671
785
|
@media (prefers-reduced-motion: reduce) {
|
|
672
786
|
.toc,
|
|
787
|
+
.markdown-body a,
|
|
673
788
|
.h1-line,
|
|
674
789
|
.ux-btn {
|
|
675
790
|
transition: none;
|
|
@@ -1182,7 +1297,8 @@ html.ux-lock body {
|
|
|
1182
1297
|
.hljs-built_in,
|
|
1183
1298
|
.hljs-type,
|
|
1184
1299
|
.hljs-meta .hljs-keyword {
|
|
1185
|
-
color: #
|
|
1300
|
+
color: #30302e;
|
|
1301
|
+
font-weight: 600;
|
|
1186
1302
|
}
|
|
1187
1303
|
|
|
1188
1304
|
.hljs-string,
|
|
@@ -1216,7 +1332,7 @@ html.ux-lock body {
|
|
|
1216
1332
|
html[data-theme="dark"] .hljs-keyword,
|
|
1217
1333
|
html[data-theme="dark"] .hljs-built_in,
|
|
1218
1334
|
html[data-theme="dark"] .hljs-type {
|
|
1219
|
-
color: #
|
|
1335
|
+
color: #eeece7;
|
|
1220
1336
|
}
|
|
1221
1337
|
|
|
1222
1338
|
html[data-theme="dark"] .hljs-string {
|
|
@@ -1285,7 +1401,7 @@ html[data-theme="dark"] .hljs-params {
|
|
|
1285
1401
|
|
|
1286
1402
|
.cover-card,
|
|
1287
1403
|
.article-hero.article-cover {
|
|
1288
|
-
border-radius:
|
|
1404
|
+
border-radius: var(--r-lg);
|
|
1289
1405
|
margin-top: 28px;
|
|
1290
1406
|
}
|
|
1291
1407
|
}
|
|
@@ -1362,16 +1478,32 @@ html[data-theme="dark"] .g-quiz-out.no { color: #f29aab; }
|
|
|
1362
1478
|
.g-flow .fl-e line, .g-flow .fl-e1 { stroke: var(--muted); stroke-width: 1.3; fill: none; }
|
|
1363
1479
|
.g-flow .fl-ah { fill: var(--muted); }
|
|
1364
1480
|
.g-flow .gc-stw { fill: rgba(180, 33, 58, 0.08); stroke: rgba(180, 33, 58, 0.45); }
|
|
1481
|
+
/* Link cards: `[text](url){card}`. Title, description and picture come from the build. */
|
|
1365
1482
|
.prose .link-cards { list-style: none; padding: 0; margin: 24px 0 32px; display: grid; gap: 12px; }
|
|
1366
1483
|
.prose .link-cards li { margin: 0; padding: 0; }
|
|
1367
|
-
.link-card { display: flex; gap: 20px; align-items: stretch; padding: 16px; border: 1px solid var(--rule); border-radius: 12px; color: inherit; text-decoration: none; }
|
|
1368
|
-
.prose a.link-card { text-decoration: none; }
|
|
1484
|
+
.link-card { display: flex; gap: 20px; align-items: stretch; padding: 16px; border: 1px solid var(--rule); border-radius: 12px; background: transparent; color: inherit; text-decoration: none; transition: border-color .15s ease, background-color .15s ease; }
|
|
1485
|
+
.prose a.link-card, .markdown-body a.link-card { text-decoration: none; padding-right: 16px; background-image: none; }
|
|
1486
|
+
.link-card:hover { border-color: var(--rule-strong, #cfcbc2); background: var(--card-hover); }
|
|
1487
|
+
.link-card:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
|
|
1369
1488
|
.lc-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
|
|
1370
|
-
.lc-site { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
|
|
1371
|
-
.lc-
|
|
1489
|
+
.lc-site { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
|
|
1490
|
+
.markdown-body .lc-site img.fav { display: block; flex: 0 0 auto; width: 14px; height: 14px; margin: 0; border-radius: 3px; object-fit: contain; }
|
|
1491
|
+
.lc-sitename { color: var(--soft); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
1372
1492
|
.lc-host { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1373
|
-
.lc-arrow { width: 10px; height: 10px; margin-left: auto; background: var(--muted); mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M3 1.5h5.5V7M8.5 1.5 1.5 8.5' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; }
|
|
1374
|
-
.lc-title { font-weight: 600; font-size: 16px; line-height: 1.45; color: var(--ink); }
|
|
1493
|
+
.lc-arrow { flex: 0 0 auto; width: 10px; height: 10px; margin-left: auto; background: var(--muted); mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M3 1.5h5.5V7M8.5 1.5 1.5 8.5' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; }
|
|
1494
|
+
.lc-title { font-weight: 600; font-size: 16px; line-height: 1.45; color: var(--ink); text-wrap: pretty; }
|
|
1495
|
+
.lc-desc { font-size: var(--fs-small); line-height: 1.55; color: var(--soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
|
1496
|
+
.lc-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: auto; padding-top: 4px; font-size: 13px; line-height: 1.5; color: var(--muted); }
|
|
1497
|
+
/* Fixed aspect ratio, so a picture arriving late never moves the text. */
|
|
1498
|
+
.markdown-body img.lc-thumb { display: block; flex: 0 0 auto; width: 168px; max-width: none; height: auto; aspect-ratio: 1.91 / 1; object-fit: cover; align-self: center; margin: 0; border: 1px solid var(--rule); border-radius: 8px; background: var(--well); }
|
|
1499
|
+
@media (max-width: 640px) {
|
|
1500
|
+
.link-card { flex-direction: column-reverse; gap: 12px; padding: 12px; }
|
|
1501
|
+
.prose a.link-card, .markdown-body a.link-card { padding-right: 12px; }
|
|
1502
|
+
.markdown-body img.lc-thumb { width: 100%; }
|
|
1503
|
+
}
|
|
1504
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1505
|
+
.link-card { transition: none; }
|
|
1506
|
+
}
|
|
1375
1507
|
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
|
|
1376
1508
|
.g-chart-t { margin: 0 0 12px; font-weight: 600; color: var(--ink); font-size: 15px; }
|
|
1377
1509
|
.g-bars { display: grid; grid-template-columns: fit-content(40%) minmax(0, 1fr) max-content; gap: 8px 10px; align-items: center; }
|