hd-garden 0.14.6 → 0.14.7
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/README.en.md +3 -3
- package/README.md +3 -3
- package/app/admin/page.tsx +3 -16
- package/app/admin/preview/[...path]/page.tsx +6 -8
- package/app/components/AdminDashboard.tsx +3 -258
- package/app/components/AdminUiPanels.tsx +5 -7
- package/app/components/ContentEmptyState.tsx +2 -10
- package/app/components/GardenAdminGuide.tsx +3 -22
- package/app/components/GardenContentGuide.tsx +0 -30
- package/app/components/MarkdownArticle.tsx +2 -3
- package/app/components/PageIntro.tsx +1 -1
- package/app/garden-modules.d.ts +2 -19
- package/app/globals.css +4 -256
- package/app/lib/content.ts +2 -8
- package/app/lib/fallback-site-config.ts +2 -6
- package/app/lib/garden-docs-meta.ts +1 -1
- package/app/lib/github-content.ts +8 -159
- package/app/lib/i18n.ts +8 -56
- package/app/lib/oss.ts +1 -1
- package/app/lib/repository-path.mjs +19 -2
- package/app/lib/ui-content.ts +4 -3
- package/app/lib/ui-model.ts +2 -0
- package/app/rss.xml/route.ts +1 -9
- package/app/site.config.ts +0 -1
- package/app/sitemap.ts +1 -10
- package/app/styles/a2.css +0 -39
- package/app/styles/shell.css +0 -9
- package/bin/garden.mjs +0 -1
- package/docs/handbook/ai-writing.md +2 -2
- package/docs/handbook/components/image.md +0 -1
- package/docs/handbook/components/link-card.md +0 -1
- package/docs/handbook/config.md +3 -8
- package/docs/handbook/deploy.md +1 -1
- package/docs/handbook/en/ai-writing.md +2 -2
- package/docs/handbook/en/components/image.md +0 -1
- package/docs/handbook/en/components/link-card.md +0 -1
- package/docs/handbook/en/config.md +2 -7
- package/docs/handbook/en/deploy.md +1 -1
- package/docs/handbook/en/index.md +1 -2
- package/docs/handbook/en/start.md +2 -7
- package/docs/handbook/en/writing.md +4 -28
- package/docs/handbook/index.md +4 -5
- package/docs/handbook/start.md +2 -7
- package/docs/handbook/writing.md +4 -28
- package/editors/dist/{garden-typora-0.14.6.zip → garden-typora-0.14.7.zip} +0 -0
- package/editors/dist/typora/manifest.json +1 -1
- package/editors/dist/typora/style.css +0 -39
- package/editors/dist/vscode/{garden-ui-0.14.6.vsix → garden-ui-0.14.7.vsix} +0 -0
- package/package.json +2 -2
- package/scripts/build-content.mjs +12 -92
- package/site.config.yaml +3 -6
- package/templates/site/AGENTS.en.md +2 -3
- package/templates/site/AGENTS.md +2 -3
- package/templates/site/site.config.en.yaml +1 -6
- package/templates/site/site.config.yaml +2 -7
- package/ui/core/workbench-eval.mjs +27 -0
- package/ui/garden/article-assets.mjs +13 -0
- package/ui/garden/post-frontmatter.mjs +31 -0
- package/ui/garden/search-index.mjs +4 -6
- package/ui/garden/site-nav.mjs +0 -1
- package/ui/garden/static-params.mjs +1 -1
- package/ui/preview/dist/garden-ui.css +0 -39
- package/ui/preview/dist/garden-ui.esm.js +1 -1
- package/ui/preview/dist/garden-ui.iife.js +1 -1
- package/app/api/admin/thoughts/[id]/route.ts +0 -44
- package/app/api/admin/thoughts/route.ts +0 -121
- package/app/components/FeedMore.tsx +0 -70
- package/app/components/ThoughtCard.tsx +0 -245
- package/app/components/ThoughtFeed.tsx +0 -41
- package/app/lib/public-thoughts.ts +0 -9
- package/app/thoughts/[slug]/page.tsx +0 -86
- package/app/thoughts/page/[n]/page.tsx +0 -44
- package/app/thoughts/page.tsx +0 -32
- package/public/images/garden/admin-studio.png +0 -0
- package/templates/site/content/thoughts/.gitkeep +0 -0
- package/ui/garden/paging.mjs +0 -30
package/app/garden-modules.d.ts
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
declare module "@garden/generated-content" {
|
|
2
|
-
|
|
3
|
-
type: "image" | "audio" | "video" | "link";
|
|
4
|
-
src: string;
|
|
5
|
-
alt?: string;
|
|
6
|
-
poster?: string;
|
|
7
|
-
mime?: string;
|
|
8
|
-
title?: string;
|
|
9
|
-
description?: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type ContentEntry = {
|
|
2
|
+
export type ContentEntry = {
|
|
13
3
|
title: string;
|
|
14
4
|
slug: string;
|
|
15
5
|
path: string;
|
|
@@ -22,7 +12,7 @@ declare module "@garden/generated-content" {
|
|
|
22
12
|
references?: { title: string; url?: string; domain?: string }[];
|
|
23
13
|
pinned?: boolean;
|
|
24
14
|
readingTime?: string;
|
|
25
|
-
kind: "post" | "column"
|
|
15
|
+
kind: "post" | "column";
|
|
26
16
|
sourcePath: string;
|
|
27
17
|
content: string;
|
|
28
18
|
column?: string;
|
|
@@ -36,18 +26,11 @@ declare module "@garden/generated-content" {
|
|
|
36
26
|
/** Resized WebP copies of a local cover, when the build had sharp. */
|
|
37
27
|
coverImage?: { src: string; srcset: string; width: number; height: number };
|
|
38
28
|
original?: string;
|
|
39
|
-
mediaType?: "image" | "audio" | "video" | "link" | "text";
|
|
40
|
-
media?: string | MediaItem[];
|
|
41
|
-
mediaAlt?: string;
|
|
42
|
-
poster?: string;
|
|
43
|
-
linkTitle?: string;
|
|
44
|
-
linkDescription?: string;
|
|
45
29
|
};
|
|
46
30
|
|
|
47
31
|
export const contentHash: string;
|
|
48
32
|
export const posts: ContentEntry[];
|
|
49
33
|
export const columns: ContentEntry[];
|
|
50
|
-
export const thoughts: ContentEntry[];
|
|
51
34
|
export type GardenDocEntry = {
|
|
52
35
|
title: string;
|
|
53
36
|
slug: string;
|
package/app/globals.css
CHANGED
|
@@ -1507,178 +1507,6 @@ button {
|
|
|
1507
1507
|
color: var(--accent);
|
|
1508
1508
|
}
|
|
1509
1509
|
|
|
1510
|
-
.thoughts-page {
|
|
1511
|
-
padding-bottom: 110px;
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1514
|
-
.thought-stream {
|
|
1515
|
-
display: grid;
|
|
1516
|
-
gap: 24px;
|
|
1517
|
-
}
|
|
1518
|
-
|
|
1519
|
-
.thought-card {
|
|
1520
|
-
padding: 24px 26px 26px;
|
|
1521
|
-
background: var(--card);
|
|
1522
|
-
border: 1px solid var(--line);
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1525
|
-
/* A thought opened from a link: only the border changes, in the ink accent. */
|
|
1526
|
-
.thought-card:target {
|
|
1527
|
-
border-color: var(--accent);
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
|
-
.thought-card > header {
|
|
1531
|
-
display: flex;
|
|
1532
|
-
justify-content: space-between;
|
|
1533
|
-
gap: 12px;
|
|
1534
|
-
color: var(--muted);
|
|
1535
|
-
font-size: 10px;
|
|
1536
|
-
}
|
|
1537
|
-
|
|
1538
|
-
.thought-kind {
|
|
1539
|
-
display: inline-flex;
|
|
1540
|
-
align-items: center;
|
|
1541
|
-
gap: 6px;
|
|
1542
|
-
color: var(--accent);
|
|
1543
|
-
font-weight: 700;
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
.thought-card > h2 {
|
|
1547
|
-
margin: 18px 0 3px;
|
|
1548
|
-
font-size: 18px;
|
|
1549
|
-
text-decoration: underline;
|
|
1550
|
-
text-underline-offset: 4px;
|
|
1551
|
-
}
|
|
1552
|
-
|
|
1553
|
-
.thought-card .markdown-body {
|
|
1554
|
-
font-size: 13px;
|
|
1555
|
-
line-height: 1.75;
|
|
1556
|
-
}
|
|
1557
|
-
|
|
1558
|
-
.thought-card .markdown-body p {
|
|
1559
|
-
margin: 12px 0 20px;
|
|
1560
|
-
}
|
|
1561
|
-
|
|
1562
|
-
.thought-permalink {
|
|
1563
|
-
width: max-content;
|
|
1564
|
-
margin-top: 24px;
|
|
1565
|
-
display: inline-flex;
|
|
1566
|
-
align-items: center;
|
|
1567
|
-
gap: 6px;
|
|
1568
|
-
color: var(--muted);
|
|
1569
|
-
font-size: 10px;
|
|
1570
|
-
border-bottom: 1px solid var(--line-strong);
|
|
1571
|
-
}
|
|
1572
|
-
|
|
1573
|
-
.thought-permalink:hover,
|
|
1574
|
-
.thought-permalink:focus-visible {
|
|
1575
|
-
color: var(--accent);
|
|
1576
|
-
}
|
|
1577
|
-
|
|
1578
|
-
.thought-detail-page {
|
|
1579
|
-
max-width: 760px;
|
|
1580
|
-
padding-top: 58px;
|
|
1581
|
-
padding-bottom: 120px;
|
|
1582
|
-
}
|
|
1583
|
-
|
|
1584
|
-
.thought-detail-page > .thought-card {
|
|
1585
|
-
margin-top: 30px;
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1588
|
-
.thought-image,
|
|
1589
|
-
.thought-video {
|
|
1590
|
-
width: 100%;
|
|
1591
|
-
max-height: 460px;
|
|
1592
|
-
display: block;
|
|
1593
|
-
object-fit: cover;
|
|
1594
|
-
border: 0;
|
|
1595
|
-
}
|
|
1596
|
-
|
|
1597
|
-
.thought-media-stack {
|
|
1598
|
-
display: grid;
|
|
1599
|
-
gap: 14px;
|
|
1600
|
-
}
|
|
1601
|
-
|
|
1602
|
-
.thought-gallery {
|
|
1603
|
-
display: grid;
|
|
1604
|
-
gap: 8px;
|
|
1605
|
-
}
|
|
1606
|
-
|
|
1607
|
-
.thought-gallery-2 {
|
|
1608
|
-
grid-template-columns: repeat(2, 1fr);
|
|
1609
|
-
}
|
|
1610
|
-
|
|
1611
|
-
.thought-gallery-3 {
|
|
1612
|
-
grid-template-columns: 1.35fr 0.65fr;
|
|
1613
|
-
grid-template-rows: repeat(2, minmax(0, 155px));
|
|
1614
|
-
}
|
|
1615
|
-
|
|
1616
|
-
.thought-gallery-3 .thought-image {
|
|
1617
|
-
height: 100%;
|
|
1618
|
-
}
|
|
1619
|
-
|
|
1620
|
-
.thought-gallery-3 .thought-image:first-child {
|
|
1621
|
-
grid-row: 1 / 3;
|
|
1622
|
-
}
|
|
1623
|
-
|
|
1624
|
-
.audio-embed {
|
|
1625
|
-
display: grid;
|
|
1626
|
-
grid-template-columns: 44px 1fr;
|
|
1627
|
-
gap: 12px;
|
|
1628
|
-
align-items: center;
|
|
1629
|
-
padding: 18px;
|
|
1630
|
-
background: var(--paper-deep);
|
|
1631
|
-
border-left: 3px solid var(--accent);
|
|
1632
|
-
}
|
|
1633
|
-
|
|
1634
|
-
.audio-embed > svg {
|
|
1635
|
-
color: var(--accent);
|
|
1636
|
-
}
|
|
1637
|
-
|
|
1638
|
-
.audio-embed strong {
|
|
1639
|
-
display: block;
|
|
1640
|
-
margin-bottom: 10px;
|
|
1641
|
-
font-size: 11px;
|
|
1642
|
-
}
|
|
1643
|
-
|
|
1644
|
-
.audio-embed audio {
|
|
1645
|
-
width: 100%;
|
|
1646
|
-
height: 36px;
|
|
1647
|
-
}
|
|
1648
|
-
|
|
1649
|
-
.link-embed {
|
|
1650
|
-
min-height: 132px;
|
|
1651
|
-
display: flex;
|
|
1652
|
-
align-items: center;
|
|
1653
|
-
justify-content: space-between;
|
|
1654
|
-
gap: 24px;
|
|
1655
|
-
padding: 22px;
|
|
1656
|
-
background: var(--paper-deep);
|
|
1657
|
-
border: 1px solid var(--line);
|
|
1658
|
-
}
|
|
1659
|
-
|
|
1660
|
-
.link-embed:hover {
|
|
1661
|
-
border-color: var(--accent);
|
|
1662
|
-
}
|
|
1663
|
-
|
|
1664
|
-
.link-embed small {
|
|
1665
|
-
color: var(--accent);
|
|
1666
|
-
font-size: 9px;
|
|
1667
|
-
text-transform: uppercase;
|
|
1668
|
-
}
|
|
1669
|
-
|
|
1670
|
-
.link-embed strong {
|
|
1671
|
-
display: block;
|
|
1672
|
-
margin: 7px 0;
|
|
1673
|
-
font-size: 14px;
|
|
1674
|
-
}
|
|
1675
|
-
|
|
1676
|
-
.link-embed p {
|
|
1677
|
-
margin: 0;
|
|
1678
|
-
color: var(--muted);
|
|
1679
|
-
font-size: 11px;
|
|
1680
|
-
}
|
|
1681
|
-
|
|
1682
1510
|
.column-feature-list {
|
|
1683
1511
|
display: grid;
|
|
1684
1512
|
gap: 24px;
|
|
@@ -4107,11 +3935,8 @@ html[data-theme="dark"] .search-footer {
|
|
|
4107
3935
|
.admin-topbar,
|
|
4108
3936
|
.admin-topbar > div,
|
|
4109
3937
|
.admin-brand,
|
|
4110
|
-
.admin-actions,
|
|
4111
3938
|
.admin-panel-heading,
|
|
4112
|
-
.admin-field-heading,
|
|
4113
3939
|
.admin-distribution-note,
|
|
4114
|
-
.admin-item-actions,
|
|
4115
3940
|
.admin-distribution-actions {
|
|
4116
3941
|
display: flex;
|
|
4117
3942
|
align-items: center;
|
|
@@ -4176,44 +4001,18 @@ html[data-theme="dark"] .search-footer {
|
|
|
4176
4001
|
|
|
4177
4002
|
.admin-notice { align-items: center; background: color-mix(in srgb, var(--accent) 7%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line)); color: var(--ink); display: flex; font-size: 13px; gap: 8px; margin: 28px 0 0; padding: 12px 14px; }
|
|
4178
4003
|
.admin-notice svg { color: var(--accent); flex: none; }
|
|
4179
|
-
|
|
4180
|
-
.admin-grid { display: grid; gap: 24px; grid-template-columns: minmax(0, 1.25fr) minmax(390px, 0.75fr); margin-top: 28px; }
|
|
4181
4004
|
.admin-panel { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
|
|
4182
4005
|
.admin-panel-heading { justify-content: space-between; margin-bottom: 24px; }
|
|
4183
4006
|
.admin-panel-heading > svg { color: var(--accent); }
|
|
4184
|
-
.admin-panel-heading span
|
|
4007
|
+
.admin-panel-heading span { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; }
|
|
4185
4008
|
.admin-panel h2 { font-size: 25px; line-height: 1.15; margin: 6px 0 0; }
|
|
4186
|
-
|
|
4187
|
-
.admin-compose-panel label { color: var(--ink); display: grid; font-size: 13px; font-weight: 650; gap: 8px; margin-top: 17px; }
|
|
4188
|
-
.admin-compose-panel input,
|
|
4189
|
-
.admin-compose-panel textarea,
|
|
4190
|
-
.admin-attachment-row input,
|
|
4191
|
-
.admin-attachment-row select { background: transparent; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); font: inherit; min-width: 0; outline-color: var(--accent); padding: 11px 12px; width: 100%; }
|
|
4192
|
-
.admin-compose-panel textarea { line-height: 1.7; resize: vertical; }
|
|
4193
|
-
|
|
4194
|
-
.admin-attachments { border-top: 1px solid var(--line); margin-top: 25px; padding-top: 20px; }
|
|
4195
|
-
.admin-field-heading { justify-content: space-between; margin-bottom: 12px; }
|
|
4196
|
-
.admin-field-heading > div { display: grid; gap: 3px; }
|
|
4197
|
-
.admin-field-heading small { color: var(--muted); font-size: 12px; }
|
|
4198
|
-
.admin-attachment-row { display: grid; gap: 8px; grid-template-columns: 92px minmax(0, 1.2fr) minmax(0, 0.9fr) 32px; margin-top: 8px; }
|
|
4199
|
-
.admin-attachment-row input, .admin-attachment-row select { font-size: 12px; padding: 9px; }
|
|
4200
|
-
|
|
4201
|
-
.admin-actions { gap: 10px; justify-content: flex-end; margin-top: 24px; }
|
|
4202
|
-
.admin-primary-button, .admin-secondary-button, .admin-quiet-button, .admin-icon-button, .admin-item-actions button, .admin-distribution-actions button { align-items: center; border: 1px solid var(--line); border-radius: 980px; cursor: pointer; display: inline-flex; font: inherit; gap: 6px; justify-content: center; }
|
|
4009
|
+
.admin-primary-button, .admin-secondary-button, .admin-quiet-button, .admin-distribution-actions button { align-items: center; border: 1px solid var(--line); border-radius: 980px; cursor: pointer; display: inline-flex; font: inherit; gap: 6px; justify-content: center; }
|
|
4203
4010
|
.admin-primary-button { background: var(--ink); border-color: var(--ink); color: var(--paper); padding: 11px 15px; }
|
|
4204
4011
|
.admin-secondary-button { background: transparent; color: var(--ink); padding: 11px 15px; }
|
|
4205
4012
|
.admin-quiet-button { background: transparent; color: var(--accent); font-size: 12px; padding: 7px 9px; }
|
|
4206
|
-
.admin-icon-button { background: transparent; color: var(--muted); padding: 8px; }
|
|
4207
4013
|
.admin-primary-button:disabled, .admin-secondary-button:disabled { cursor: wait; opacity: 0.58; }
|
|
4208
|
-
|
|
4209
|
-
.admin-thought-list { border-top: 1px solid var(--line); }
|
|
4210
|
-
.admin-thought-list article { align-items: start; border-bottom: 1px solid var(--line); display: flex; gap: 16px; justify-content: space-between; padding: 18px 0; }
|
|
4211
|
-
.admin-thought-list h3, .admin-catalog h3 { font-size: 15px; line-height: 1.35; margin: 8px 0 5px; }
|
|
4212
|
-
.admin-thought-list p { color: var(--muted); font-size: 12px; line-height: 1.55; margin: 0; }
|
|
4213
4014
|
.admin-status { border: 1px solid var(--line); color: var(--muted); font-size: 10px; padding: 3px 5px; }
|
|
4214
|
-
.admin-
|
|
4215
|
-
.admin-item-actions { flex: none; gap: 7px; }
|
|
4216
|
-
.admin-item-actions a, .admin-item-actions button { background: transparent; color: var(--muted); font-size: 12px; padding: 6px; text-decoration: none; }
|
|
4015
|
+
.admin-catalog h3 { font-size: 15px; line-height: 1.35; margin: 8px 0 5px; }
|
|
4217
4016
|
.admin-empty { color: var(--muted); font-size: 13px; padding: 22px 0; }
|
|
4218
4017
|
|
|
4219
4018
|
.admin-distribution-panel { margin-top: 24px; }
|
|
@@ -4238,12 +4037,10 @@ html[data-theme="dark"] .search-footer {
|
|
|
4238
4037
|
|
|
4239
4038
|
@media (max-width: 900px) {
|
|
4240
4039
|
.admin-shell, .admin-access-page { width: min(100% - 36px, 720px); padding-top: 18px; }
|
|
4241
|
-
.admin-hero
|
|
4040
|
+
.admin-hero { grid-template-columns: 1fr; }
|
|
4242
4041
|
.admin-hero { gap: 28px; padding: 55px 0 35px; }
|
|
4243
4042
|
.admin-metrics { max-width: 440px; }
|
|
4244
4043
|
.admin-panel { padding: 20px; }
|
|
4245
|
-
.admin-attachment-row { grid-template-columns: 82px minmax(0, 1fr) 32px; }
|
|
4246
|
-
.admin-attachment-row input:nth-of-type(2) { grid-column: 2; }
|
|
4247
4044
|
.admin-catalog article { align-items: start; flex-direction: column; }
|
|
4248
4045
|
.admin-distribution-actions { justify-content: flex-start; }
|
|
4249
4046
|
}
|
|
@@ -4253,11 +4050,6 @@ html[data-theme="dark"] .search-footer {
|
|
|
4253
4050
|
.admin-topbar > div { gap: 0; }
|
|
4254
4051
|
.admin-hero h1 { font-size: 38px; }
|
|
4255
4052
|
.admin-metrics dd { font-size: 25px; }
|
|
4256
|
-
.admin-field-heading { align-items: start; gap: 12px; }
|
|
4257
|
-
.admin-attachment-row { grid-template-columns: 1fr 36px; }
|
|
4258
|
-
.admin-attachment-row select, .admin-attachment-row input { grid-column: 1; }
|
|
4259
|
-
.admin-attachment-row button { grid-column: 2; grid-row: 1; }
|
|
4260
|
-
.admin-thought-list article { flex-direction: column; }
|
|
4261
4053
|
}
|
|
4262
4054
|
|
|
4263
4055
|
@media (max-width: 680px) {
|
|
@@ -4361,14 +4153,6 @@ html[data-theme="dark"] .search-footer {
|
|
|
4361
4153
|
margin: 0;
|
|
4362
4154
|
}
|
|
4363
4155
|
|
|
4364
|
-
.thought-card {
|
|
4365
|
-
padding: 19px;
|
|
4366
|
-
}
|
|
4367
|
-
|
|
4368
|
-
.thought-card > header {
|
|
4369
|
-
align-items: flex-start;
|
|
4370
|
-
}
|
|
4371
|
-
|
|
4372
4156
|
.column-feature {
|
|
4373
4157
|
grid-template-columns: 1fr;
|
|
4374
4158
|
}
|
|
@@ -4440,19 +4224,6 @@ html[data-theme="dark"] .search-footer {
|
|
|
4440
4224
|
padding: 0 16px 14px;
|
|
4441
4225
|
}
|
|
4442
4226
|
|
|
4443
|
-
.thought-gallery-2,
|
|
4444
|
-
.thought-gallery-3 {
|
|
4445
|
-
grid-template-columns: 1fr;
|
|
4446
|
-
grid-template-rows: none;
|
|
4447
|
-
}
|
|
4448
|
-
|
|
4449
|
-
.thought-gallery-3 .thought-image,
|
|
4450
|
-
.thought-gallery-3 .thought-image:first-child {
|
|
4451
|
-
grid-row: auto;
|
|
4452
|
-
height: auto;
|
|
4453
|
-
max-height: 360px;
|
|
4454
|
-
}
|
|
4455
|
-
|
|
4456
4227
|
.series-nav ol {
|
|
4457
4228
|
grid-template-columns: 1fr;
|
|
4458
4229
|
}
|
|
@@ -5446,12 +5217,6 @@ html[data-theme="dark"] .search-footer {
|
|
|
5446
5217
|
color: var(--garden-ink);
|
|
5447
5218
|
}
|
|
5448
5219
|
|
|
5449
|
-
.admin-grid {
|
|
5450
|
-
grid-template-columns: 1fr;
|
|
5451
|
-
gap: 16px;
|
|
5452
|
-
margin-top: 20px;
|
|
5453
|
-
}
|
|
5454
|
-
|
|
5455
5220
|
.admin-panel {
|
|
5456
5221
|
border: 0;
|
|
5457
5222
|
border-radius: 20px;
|
|
@@ -5468,7 +5233,6 @@ html[data-theme="dark"] .search-footer {
|
|
|
5468
5233
|
font-weight: 600;
|
|
5469
5234
|
}
|
|
5470
5235
|
|
|
5471
|
-
.admin-field-heading span,
|
|
5472
5236
|
.admin-quiet-button,
|
|
5473
5237
|
.admin-distribution-actions button:first-child {
|
|
5474
5238
|
color: var(--garden-ink);
|
|
@@ -5476,22 +5240,6 @@ html[data-theme="dark"] .search-footer {
|
|
|
5476
5240
|
font-weight: 500;
|
|
5477
5241
|
}
|
|
5478
5242
|
|
|
5479
|
-
.admin-field-heading span {
|
|
5480
|
-
font-size: 14px;
|
|
5481
|
-
}
|
|
5482
|
-
|
|
5483
|
-
.admin-field-heading small {
|
|
5484
|
-
color: var(--garden-muted);
|
|
5485
|
-
}
|
|
5486
|
-
|
|
5487
|
-
.admin-compose-panel label {
|
|
5488
|
-
font-weight: 500;
|
|
5489
|
-
}
|
|
5490
|
-
|
|
5491
|
-
.admin-compose-panel input,
|
|
5492
|
-
.admin-compose-panel textarea,
|
|
5493
|
-
.admin-attachment-row input,
|
|
5494
|
-
.admin-attachment-row select,
|
|
5495
5243
|
.ui-studio-instruction {
|
|
5496
5244
|
border: 0;
|
|
5497
5245
|
border-radius: 12px;
|
package/app/lib/content.ts
CHANGED
|
@@ -6,10 +6,8 @@ import {
|
|
|
6
6
|
gardenDocsEn,
|
|
7
7
|
gardenIndexDocEn,
|
|
8
8
|
posts,
|
|
9
|
-
thoughts,
|
|
10
9
|
type ContentEntry,
|
|
11
10
|
type GardenDocEntry,
|
|
12
|
-
type MediaItem,
|
|
13
11
|
} from "@garden/generated-content";
|
|
14
12
|
import GithubSlugger from "github-slugger";
|
|
15
13
|
import { canonicalSiteDate } from "../../scripts/site-date.mjs";
|
|
@@ -23,8 +21,8 @@ import { articleUsesHeadingNumbers, autoNumbersHeadings, splitHeadingNumber } fr
|
|
|
23
21
|
import { siteHref } from "./site-href";
|
|
24
22
|
import { siteLang, ui } from "./i18n";
|
|
25
23
|
|
|
26
|
-
export { columns, gardenDocs, gardenDocsEn, gardenIndexDoc, gardenIndexDocEn, posts
|
|
27
|
-
export type { ContentEntry, GardenDocEntry
|
|
24
|
+
export { columns, gardenDocs, gardenDocsEn, gardenIndexDoc, gardenIndexDocEn, posts };
|
|
25
|
+
export type { ContentEntry, GardenDocEntry };
|
|
28
26
|
|
|
29
27
|
export const postHref = (post: Pick<ContentEntry, "path">) => siteHref(`/blog/${post.path}`);
|
|
30
28
|
export const gardenDocHref = (doc: Pick<GardenDocEntry, "path">) => siteHref(`/garden/${doc.path}`);
|
|
@@ -41,7 +39,6 @@ export const columnOfPost = (post: Pick<ContentEntry, "path">) => {
|
|
|
41
39
|
return entry?.column ? { slug: entry.column, title: entry.columnTitle ?? entry.column } : undefined;
|
|
42
40
|
};
|
|
43
41
|
export const columnIndexHref = (slug: string) => siteHref(`/columns/#${slug}`);
|
|
44
|
-
export const thoughtHref = (slug: string) => siteHref(`/thoughts/${slug}`);
|
|
45
42
|
|
|
46
43
|
export const formatDate = (value: string, withTime = false) => {
|
|
47
44
|
if (!withTime) return demoDateLabel(value, siteLang);
|
|
@@ -115,9 +112,6 @@ export const estimateWordCount = (markdown: string) => {
|
|
|
115
112
|
export const findPost = (path: string): ContentEntry | undefined =>
|
|
116
113
|
posts.find((post) => post.path === path);
|
|
117
114
|
|
|
118
|
-
export const findThought = (slug: string): ContentEntry | undefined =>
|
|
119
|
-
thoughts.find((thought) => thought.slug === slug);
|
|
120
|
-
|
|
121
115
|
export const findGardenDoc = (path: string): GardenDocEntry | undefined =>
|
|
122
116
|
gardenDocs.find((doc) => doc.path === path);
|
|
123
117
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const siteConfig = {
|
|
2
2
|
name: "Garden",
|
|
3
3
|
tagline: "写作 · 记录 · 保持好奇",
|
|
4
|
-
description: "
|
|
4
|
+
description: "文章和专栏。",
|
|
5
5
|
locale: "zh_CN",
|
|
6
6
|
author: {
|
|
7
7
|
name: "Your Name",
|
|
@@ -18,10 +18,6 @@ export const siteConfig = {
|
|
|
18
18
|
title: "博文",
|
|
19
19
|
subtitle: "写完的长文。",
|
|
20
20
|
},
|
|
21
|
-
thoughts: {
|
|
22
|
-
title: "随想",
|
|
23
|
-
subtitle: "短笔记、图片和链接。",
|
|
24
|
-
},
|
|
25
21
|
columns: {
|
|
26
22
|
title: "专栏",
|
|
27
23
|
subtitle: "按顺序读的一组文章。",
|
|
@@ -32,7 +28,7 @@ export const siteConfig = {
|
|
|
32
28
|
heading: "关于",
|
|
33
29
|
paragraphs: [
|
|
34
30
|
"一名工程师。平时写代码,也把想清楚的问题记下来。",
|
|
35
|
-
"
|
|
31
|
+
"这里放文章和专栏。",
|
|
36
32
|
],
|
|
37
33
|
quote: "",
|
|
38
34
|
focus: [
|
|
@@ -110,7 +110,7 @@ export const NAV_SHORT_TITLE: Record<string, string> = {
|
|
|
110
110
|
"ai-writing": "用 AI 写作",
|
|
111
111
|
config: "站点与专栏配置",
|
|
112
112
|
deploy: "发布到 GitHub Pages",
|
|
113
|
-
writing: "
|
|
113
|
+
writing: "写文章",
|
|
114
114
|
design: "阅读排版是怎么工作的",
|
|
115
115
|
components: "组件总览",
|
|
116
116
|
"components/card": "知识卡片",
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import type { ContentEntry, MediaItem } from "./content";
|
|
4
|
-
import { repositoryPostPath } from "./repository-path.mjs";
|
|
5
|
-
import { canonicalSiteDate, formatAuthorDate } from "../../scripts/site-date.mjs";
|
|
6
|
-
|
|
7
|
-
const matterOptions = {
|
|
8
|
-
engines: {
|
|
9
|
-
yaml: {
|
|
10
|
-
parse: (input: string) => parseYaml(input) ?? {},
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
};
|
|
1
|
+
import { withPostPinned } from "../../ui/garden/post-frontmatter.mjs";
|
|
2
|
+
import { isRepositoryManuscript, repositoryPostPath } from "./repository-path.mjs";
|
|
14
3
|
|
|
15
4
|
// GITHUB_API_URL lets GitHub Enterprise (and local mocks) replace the public API.
|
|
16
5
|
const githubApi = () => (process.env.GITHUB_API_URL ?? "https://api.github.com").replace(/\/+$/u, "");
|
|
@@ -21,20 +10,6 @@ type RepositoryFile = {
|
|
|
21
10
|
sha?: string;
|
|
22
11
|
};
|
|
23
12
|
|
|
24
|
-
type RepositoryDirectoryEntry = {
|
|
25
|
-
name: string;
|
|
26
|
-
path: string;
|
|
27
|
-
type: "file" | "dir";
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export type RepositoryThought = ContentEntry & {
|
|
31
|
-
id: string;
|
|
32
|
-
status: "draft" | "published";
|
|
33
|
-
sha?: string;
|
|
34
|
-
tags: string[];
|
|
35
|
-
media: MediaItem[];
|
|
36
|
-
};
|
|
37
|
-
|
|
38
13
|
function repositoryConfig() {
|
|
39
14
|
const repository = process.env.CONTENT_REPOSITORY;
|
|
40
15
|
const token = process.env.CONTENT_GITHUB_TOKEN;
|
|
@@ -72,70 +47,10 @@ function base64ToUtf8(value: string) {
|
|
|
72
47
|
);
|
|
73
48
|
}
|
|
74
49
|
|
|
75
|
-
function isStringArray(value: unknown): value is string[] {
|
|
76
|
-
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function isMedia(value: unknown): value is MediaItem[] {
|
|
80
|
-
return Array.isArray(value) && value.every((item) => {
|
|
81
|
-
if (!item || typeof item !== "object") return false;
|
|
82
|
-
const candidate = item as Record<string, unknown>;
|
|
83
|
-
return ["image", "audio", "video", "link"].includes(String(candidate.type)) &&
|
|
84
|
-
typeof candidate.src === "string";
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
50
|
function fileStem(filePath: string) {
|
|
89
51
|
return (filePath.split("/").pop() ?? "").replace(/\.md$/u, "");
|
|
90
52
|
}
|
|
91
53
|
|
|
92
|
-
function normalizeThought(source: string, filePath: string, sha?: string): RepositoryThought | null {
|
|
93
|
-
const parsed = matter(source, matterOptions);
|
|
94
|
-
const data = parsed.data;
|
|
95
|
-
const slug = fileStem(filePath);
|
|
96
|
-
if (typeof data.title !== "string" || typeof data.date !== "string" || !canonicalSiteDate(data.date) || !slug) {
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
if (data.slug !== undefined && data.slug !== slug) return null;
|
|
100
|
-
const media = isMedia(data.media) ? data.media : [];
|
|
101
|
-
const status = data.draft === true ? "draft" : "published";
|
|
102
|
-
return {
|
|
103
|
-
id: slug,
|
|
104
|
-
slug,
|
|
105
|
-
path: slug,
|
|
106
|
-
title: data.title,
|
|
107
|
-
date: data.date,
|
|
108
|
-
tags: isStringArray(data.tags) ? data.tags : [],
|
|
109
|
-
mediaType: media[0]?.type ?? "text",
|
|
110
|
-
media,
|
|
111
|
-
kind: "thought",
|
|
112
|
-
draft: status === "draft",
|
|
113
|
-
sourcePath: filePath,
|
|
114
|
-
content: parsed.content.trim(),
|
|
115
|
-
status,
|
|
116
|
-
sha,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function serializeThought(thought: {
|
|
121
|
-
slug: string;
|
|
122
|
-
title: string;
|
|
123
|
-
content: string;
|
|
124
|
-
tags: string[];
|
|
125
|
-
media: MediaItem[];
|
|
126
|
-
status: "draft" | "published";
|
|
127
|
-
date?: string;
|
|
128
|
-
}) {
|
|
129
|
-
return matter.stringify(thought.content.trim().concat("\n"), {
|
|
130
|
-
title: thought.title,
|
|
131
|
-
date: thought.date ?? formatAuthorDate(),
|
|
132
|
-
tags: thought.tags,
|
|
133
|
-
mediaType: thought.media[0]?.type ?? "text",
|
|
134
|
-
media: thought.media,
|
|
135
|
-
draft: thought.status === "draft",
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
54
|
async function requestRepository(path: string, init?: RequestInit) {
|
|
140
55
|
const config = repositoryConfig();
|
|
141
56
|
if (!config) throw new Error("未配置 CONTENT_REPOSITORY 或 CONTENT_GITHUB_TOKEN。");
|
|
@@ -177,71 +92,6 @@ export async function readRepositoryFile(path: string) {
|
|
|
177
92
|
return { source: base64ToUtf8(file.content), sha: file.sha };
|
|
178
93
|
}
|
|
179
94
|
|
|
180
|
-
export async function listRepositoryThoughts() {
|
|
181
|
-
const config = repositoryConfig();
|
|
182
|
-
if (!config) return [] as RepositoryThought[];
|
|
183
|
-
const { response } = await requestRepository("content/thoughts");
|
|
184
|
-
if (response.status === 404) return [] as RepositoryThought[];
|
|
185
|
-
if (!response.ok) throw new Error("无法读取 GitHub 随想目录。");
|
|
186
|
-
const entries = (await response.json()) as RepositoryDirectoryEntry[];
|
|
187
|
-
const thoughts = await Promise.all(
|
|
188
|
-
entries
|
|
189
|
-
.filter((entry) => entry.type === "file" && entry.name.endsWith(".md"))
|
|
190
|
-
.map(async (entry) => {
|
|
191
|
-
const file = await readRepositoryFile(entry.path);
|
|
192
|
-
return file ? normalizeThought(file.source, entry.path, file.sha) : null;
|
|
193
|
-
}),
|
|
194
|
-
);
|
|
195
|
-
return thoughts
|
|
196
|
-
.filter((thought): thought is RepositoryThought => Boolean(thought))
|
|
197
|
-
.sort((left, right) => {
|
|
198
|
-
const rightTime = Date.parse(canonicalSiteDate(right.date) ?? "");
|
|
199
|
-
const leftTime = Date.parse(canonicalSiteDate(left.date) ?? "");
|
|
200
|
-
return rightTime - leftTime;
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
export async function createRepositoryThought(input: Omit<RepositoryThought, "id" | "kind" | "path" | "sourcePath" | "draft" | "sha" | "mediaType">) {
|
|
205
|
-
const path = `content/thoughts/${input.slug}.md`;
|
|
206
|
-
const existing = await readRepositoryFile(path);
|
|
207
|
-
if (existing) throw new Error("这个随想 slug 已存在,请稍后重试。");
|
|
208
|
-
const source = serializeThought(input);
|
|
209
|
-
const { response } = await mutateRepository(path, "PUT", {
|
|
210
|
-
message: `content: 发布随想 ${input.title}`,
|
|
211
|
-
content: utf8ToBase64(source),
|
|
212
|
-
});
|
|
213
|
-
if (!response.ok) throw new Error("GitHub 未接受这次随想提交。");
|
|
214
|
-
const result = (await response.json()) as { content?: { sha?: string } };
|
|
215
|
-
return normalizeThought(source, path, result.content?.sha) as RepositoryThought;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
export async function updateRepositoryThought(slug: string, status: "draft" | "published") {
|
|
219
|
-
const path = `content/thoughts/${slug}.md`;
|
|
220
|
-
const existing = await readRepositoryFile(path);
|
|
221
|
-
if (!existing) throw new Error("未找到对应随想。");
|
|
222
|
-
const thought = normalizeThought(existing.source, path, existing.sha);
|
|
223
|
-
if (!thought) throw new Error("随想内容格式不正确。");
|
|
224
|
-
const source = serializeThought({ ...thought, status, date: status === "published" ? formatAuthorDate() : thought.date });
|
|
225
|
-
const { response } = await mutateRepository(path, "PUT", {
|
|
226
|
-
message: `content: ${status === "published" ? "发布" : "撤回"}随想 ${thought.title}`,
|
|
227
|
-
content: utf8ToBase64(source),
|
|
228
|
-
sha: existing.sha,
|
|
229
|
-
});
|
|
230
|
-
if (!response.ok) throw new Error("GitHub 未接受这次状态更新。");
|
|
231
|
-
return normalizeThought(source, path) as RepositoryThought;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
export async function deleteRepositoryThought(slug: string) {
|
|
235
|
-
const path = `content/thoughts/${slug}.md`;
|
|
236
|
-
const existing = await readRepositoryFile(path);
|
|
237
|
-
if (!existing) throw new Error("未找到对应随想。");
|
|
238
|
-
const { response } = await mutateRepository(path, "DELETE", {
|
|
239
|
-
message: `content: 删除随想 ${slug}`,
|
|
240
|
-
sha: existing.sha,
|
|
241
|
-
});
|
|
242
|
-
if (!response.ok) throw new Error("GitHub 未接受这次删除请求。");
|
|
243
|
-
}
|
|
244
|
-
|
|
245
95
|
export async function updateRepositoryPostPinned(input: {
|
|
246
96
|
sourcePath: string;
|
|
247
97
|
slug: string;
|
|
@@ -251,14 +101,11 @@ export async function updateRepositoryPostPinned(input: {
|
|
|
251
101
|
const repositoryPath = repositoryPostPath(input.sourcePath);
|
|
252
102
|
const existing = await readRepositoryFile(repositoryPath);
|
|
253
103
|
if (!existing) throw new Error("未找到对应博文。");
|
|
254
|
-
const parsed = matter(existing.source);
|
|
255
104
|
if (fileStem(repositoryPath) !== input.slug) {
|
|
256
105
|
throw new Error("博文标识不匹配,已拒绝修改。");
|
|
257
106
|
}
|
|
258
|
-
const
|
|
259
|
-
if (input.pinned
|
|
260
|
-
else delete data.pinned;
|
|
261
|
-
const source = matter.stringify(`${parsed.content.trim()}\n`, data);
|
|
107
|
+
const source = withPostPinned(existing.source, input.pinned);
|
|
108
|
+
if (source === existing.source) return { slug: input.slug, pinned: input.pinned };
|
|
262
109
|
const { response } = await mutateRepository(repositoryPath, "PUT", {
|
|
263
110
|
message: `content: ${input.pinned ? "置顶" : "取消置顶"}博文 ${input.title}`,
|
|
264
111
|
content: utf8ToBase64(source),
|
|
@@ -278,8 +125,10 @@ export async function listContentMarkdown() {
|
|
|
278
125
|
const response = await fetch(url, { headers: headers(config.token), cache: "no-store" });
|
|
279
126
|
if (!response.ok) throw new Error("无法读取 GitHub 仓库目录。");
|
|
280
127
|
const tree = (await response.json()) as { tree?: Array<{ path: string; type: string; sha: string }> };
|
|
281
|
-
|
|
282
|
-
|
|
128
|
+
const entries = (tree.tree ?? []).filter((entry) => entry.type === "blob");
|
|
129
|
+
const paths = new Set(entries.map((entry) => entry.path));
|
|
130
|
+
return entries
|
|
131
|
+
.filter((entry) => isRepositoryManuscript(entry.path, paths))
|
|
283
132
|
.map((entry) => ({ path: entry.path, sha: entry.sha }));
|
|
284
133
|
}
|
|
285
134
|
|