Skip to content

Commit 0cf343b

Browse files
RuitingMaclaude
andcommitted
Site: mark drafts in the lobby kind line
Append "· 草稿" to each unpublished entry's kind label and dim the whole anchor to 0.55 (back to 1.0 on hover so the row's still clickable-feeling). The marker only ever renders in dev — PROD's filter strips drafts from the listing entirely, so the prop is always false there. Implementation note: the dim is on `<a>` not `<li>` because the `<li>`'s `.enter` keyframe pins opacity = 1 with animation-fill-mode: both, beating any later `.is-draft { opacity }` rule on the same element. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e85599f commit 0cf343b

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

src/pages/index.astro

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ import { SKETCHES } from '../lib/sketches';
77
// Sketches remain hand-authored .astro pages (their layouts are bespoke,
88
// so a shared template fights them). The registry lives in src/lib/sketches.ts
99
// so each sketch page can import `isDraft` and gate itself in PROD.
10-
const sketches = SKETCHES.filter((s) => import.meta.env.DEV || s.published);
10+
// `draft` is uniform with the essay shape below so the listing template
11+
// can render the "草稿" marker without caring which collection it came from.
12+
const sketches = SKETCHES
13+
.filter((s) => import.meta.env.DEV || s.published)
14+
.map((s) => ({ ...s, draft: !s.published }));
1115
1216
// Long-form essays come from the content collection.
1317
const essayEntries = await getCollection('essays', (e) => import.meta.env.DEV || e.data.published);
@@ -17,6 +21,7 @@ const essays = essayEntries.map((e) => ({
1721
date: e.data.date,
1822
kind: e.data.kind,
1923
summary: e.data.summary,
24+
draft: !e.data.published,
2025
}));
2126
2227
// Date desc, tie-break by href so order is deterministic. Essays sort
@@ -38,14 +43,14 @@ const entries = [...sketches, ...essays].sort((a, b) => {
3843

3944
<ul class="sketches">
4045
{entries.map((s, idx) => (
41-
<li class="enter" style={`--i: ${idx + 2};`}>
46+
<li class:list={['enter', { 'is-draft': s.draft }]} style={`--i: ${idx + 2};`}>
4247
<a href={s.href} data-heat-trigger>
4348
<div class="row">
4449
<span class="title">{s.title}</span>
4550
<span class="date">{s.date}</span>
4651
</div>
4752
<p class="summary">{s.summary}</p>
48-
<span class="kind">— {s.kind}</span>
53+
<span class="kind">— {s.kind}{s.draft && <span class="draft-tag"> · 草稿</span>}</span>
4954
</a>
5055
</li>
5156
))}
@@ -143,4 +148,20 @@ const entries = [...sketches, ...essays].sort((a, b) => {
143148
font-size: 0.65rem;
144149
color: var(--accent);
145150
}
151+
/* Draft entries appear only in dev (PROD filters them out). The marker
152+
sits on the kind line — same scale as the rest of the meta so it
153+
doesn't shout — and the row anchor dims slightly so a quick scan
154+
can tell drafts and shipped pieces apart at a glance. The dim is on
155+
the <a>, not the <li>, because the <li>'s `.enter` keyframe pins
156+
opacity = 1 with animation-fill-mode: both. */
157+
ul.sketches li.is-draft a {
158+
opacity: 0.55;
159+
transition: opacity 200ms ease;
160+
}
161+
ul.sketches li.is-draft a:hover {
162+
opacity: 1;
163+
}
164+
.draft-tag {
165+
color: var(--muted);
166+
}
146167
</style>

0 commit comments

Comments
 (0)