Skip to content

Commit e85599f

Browse files
RuitingMaclaude
andcommitted
Site: invert draft default — publish-by-opt-in
Rename the schema field `draft: boolean` → `published: boolean` (default false) so every essay and sketch starts unpublished. To ship, set `published: true` in the entry's frontmatter (or in the SKETCHES row). Why the rename: `draft: false` is a double-negative for what's conceptually "I've polished this and it's official"; `published: true` reads as the affirmative act of publishing, matching the new mental model where draft is the resting state and publication is the deliberate gesture. Filter sites flip from `!e.data.draft` to `e.data.published`. The per-page `isDraft(slug)` helper survives unchanged at call sites (clinamen / hello-world / smoke / shi PROD redirects); internally it now returns `!sketch.published`. Existing entries: - zhui-guang.md: gain `published: true` (only currently-shipped essay) - clinamen, smoke (already-shipped sketches): gain `published: true` - hello-world, shi (drafted sketches): drop the now-redundant `draft: true` - jeux-deau-test + 5 score-themed essay drafts: drop `draft: true` Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 61003d6 commit e85599f

11 files changed

Lines changed: 19 additions & 20 deletions

src/content.config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ const essays = defineCollection({
1919
// Name of a stage component in the STAGES registry inside
2020
// src/pages/essays/[...slug].astro. Omit for a prose-only essay.
2121
stage: z.string().optional(),
22-
// Hide from the listing and skip building in PROD. Dev still renders.
23-
draft: z.boolean().default(false),
22+
// Publish-by-opt-in: every essay starts as a draft (hidden in PROD,
23+
// dev still renders). Set `published: true` to ship.
24+
published: z.boolean().default(false),
2425
}),
2526
});
2627

src/content/essays/dong-jie-de-bao-tou.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ date: "2026-05-04"
44
kind: ESSAY
55
summary: 谱面在动,谱号、调号、拍号永远在最左边——这块小区域比看上去复杂。
66
tint: rust
7-
draft: true
87
---
98

109
import Score from '../../components/Score.astro';

src/content/essays/gun-pu-de-zha-fa.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ date: "2026-05-04"
44
kind: ESSAY
55
summary: 从 MEI 到一个能在网页里横向滚动、声音同步的乐谱组件。
66
tint: dune
7-
draft: true
87
---
98

109
import Score from '../../components/Score.astro';

src/content/essays/jeux-deau-test.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ title: Score 组件测试页
33
date: "2026-04-26"
44
kind: NOTE
55
summary: 全部 5 个 Score 实例集中在一页,用于回归 / 压力测试。永久 dev-only。
6-
draft: true
76
---
87

98
import Score from '../../components/Score.astro';

src/content/essays/pei-pu.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ date: "2026-05-04"
44
kind: NOTE
55
summary: 一种横向滚动的乐谱。它不替你看,它陪你看。
66
tint: plum
7-
draft: true
87
---
98

109
import Score from '../../components/Score.astro';

src/content/essays/shui-zhi-xi-xi.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ date: "2026-05-04"
44
kind: NOTE
55
summary: 拉威尔 1901 年的水。从一个 Eadd9 落下来。
66
tint: mist
7-
draft: true
87
---
98

109
import Score from '../../components/Score.astro';

src/content/essays/xi-tong-pai-zhun.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ date: "2026-05-04"
44
kind: ESSAY
55
summary: 谱面要滚得准,声音要响得准,两边对的是同一个时间——但它们用的不是同一只钟。
66
tint: moss
7-
draft: true
87
---
98

109
import Score from '../../components/Score.astro';

src/content/essays/zhui-guang.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ kind: NOTE
55
summary: 关于注视、追光,以及阅读位置。
66
tint: moss
77
stage: begin
8+
published: true
89
---
910

1011
<section data-cue="empty">

src/lib/sketches.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
// here via the page's `slug` prop, so each sketch page only declares which
44
// sketch it is — no duplicated title/date/kind/tint.
55
//
6-
// Mark `draft: true` to hide an entry from the listing and redirect direct
7-
// visits to /404 in production builds. Dev still serves them normally so you
8-
// can preview. (The redirect target relies on src/pages/404.astro existing;
6+
// Publish-by-opt-in: every entry starts as a draft. Set `published: true`
7+
// to ship — drafts are hidden from the listing and redirect direct visits
8+
// to /404 in production. Dev still serves them normally so you can
9+
// preview. (The redirect target relies on src/pages/404.astro existing;
910
// if you ever rename or remove it, drafts will fall through to the host's
1011
// default 404 page.)
1112
import type { Kind } from './kinds';
@@ -20,20 +21,22 @@ export type Sketch = {
2021
kind: Kind;
2122
summary: string;
2223
tint?: Tint;
23-
draft?: boolean;
24+
published?: boolean;
2425
};
2526

2627
export const SKETCHES: Sketch[] = [
27-
{ slug: 'shi', href: '/sketches/shi/', title: '识', date: '2026-04-22', kind: 'AI · INTERACTIVE', summary: '机器识字。', tint: 'moss', draft: true },
28-
{ slug: 'clinamen', href: '/sketches/clinamen/', title: 'Clinamen', date: '2026-04-20', kind: 'AUDIO · GENERATIVE', summary: '河灯散布于水面。', tint: 'rust' },
29-
{ slug: 'smoke', href: '/sketches/smoke/', title: 'Smoke', date: '2026-04-19', kind: 'GENERATIVE', summary: '烟。', tint: 'plum' },
30-
{ slug: 'hello-world', href: '/sketches/hello-world/', title: 'Flow Field', date: '2026-04-18', kind: 'GENERATIVE', summary: '漂流点阵。', tint: 'mist', draft: true },
28+
{ slug: 'shi', href: '/sketches/shi/', title: '识', date: '2026-04-22', kind: 'AI · INTERACTIVE', summary: '机器识字。', tint: 'moss' },
29+
{ slug: 'clinamen', href: '/sketches/clinamen/', title: 'Clinamen', date: '2026-04-20', kind: 'AUDIO · GENERATIVE', summary: '河灯散布于水面。', tint: 'rust', published: true },
30+
{ slug: 'smoke', href: '/sketches/smoke/', title: 'Smoke', date: '2026-04-19', kind: 'GENERATIVE', summary: '烟。', tint: 'plum', published: true },
31+
{ slug: 'hello-world', href: '/sketches/hello-world/', title: 'Flow Field', date: '2026-04-18', kind: 'GENERATIVE', summary: '漂流点阵。', tint: 'mist' },
3132
];
3233

3334
export function getSketch(slug: string): Sketch | undefined {
3435
return SKETCHES.find((s) => s.slug === slug);
3536
}
3637

38+
/** Per-page guard for draft sketches. Each sketch page imports this
39+
* and redirects to /404 in PROD when its slug is unpublished. */
3740
export function isDraft(slug: string): boolean {
38-
return getSketch(slug)?.draft === true;
41+
return !getSketch(slug)?.published;
3942
}

src/pages/essays/[...slug].astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import EssayLayout from '../../layouts/EssayLayout.astro';
44
import BeginSketch from '../../components/BeginSketch.astro';
55
66
export async function getStaticPaths() {
7-
const essays = await getCollection('essays', (e) => import.meta.env.DEV || !e.data.draft);
7+
const essays = await getCollection('essays', (e) => import.meta.env.DEV || e.data.published);
88
return essays.map((entry) => ({
99
params: { slug: entry.id },
1010
props: { entry },

0 commit comments

Comments
 (0)