dsh-zdiary-kit 3.14.2 → 3.16.0

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.
@@ -4,7 +4,7 @@
4
4
  * 设计边界(和设置页的写 API 完全分开):
5
5
  * · 只挂 4 条 GET 路由,全部在 /dsh-zdiary-kit 下,和 DSH 同端口,不自己 listen;
6
6
  * · 方法门:GET / HEAD 以外一律 405,默认拒绝 —— 不是「没写 POST 就算只读」;
7
- * · 副作用门:只调 hasNotebook / scanNotes / searchNotes / readNote / backlinksOf,
7
+ * · 副作用门:只调 hasNotebook / scanNotes / searchNotes / readNote / backlinksOf / outlinksOf,
8
8
  * **不调 ensureNotebook**(那会建库)、不跑 init / index / install;
9
9
  * · 面门:不读 /api/settings 的 snapshot,不返回 zkPath / 配置文件路径 / absPath;
10
10
  * · 地址门:只认回环(Host + 对端地址),DSH 绑到 0.0.0.0 时视图也不会跟着上网。
@@ -15,7 +15,7 @@ import fs from 'node:fs';
15
15
  import path from 'node:path';
16
16
  import { isLoopback, json, ROUTE_BASE } from '../../lib/http.js';
17
17
  import { config } from '../../config/store.js';
18
- import { absPathOf, attachSummaries, backlinksOf, hasNotebook, isUnderDir, localDate, readNote, scanNotes, searchNotes, ZkError } from '../../lib/zk.js';
18
+ import { absPathOf, attachSummaries, backlinksOf, hasNotebook, inArchive, isUnderDir, localDate, outlinksOf, readNote, scanNotes, searchNotes, ZkError } from '../../lib/zk.js';
19
19
  import { isMetaPath } from '../../lib/meta.js';
20
20
  import { buildMemoryPayload, formatFileShares } from '../../lib/memory.js';
21
21
  import { RETIRED_ENTRY_RE } from '../../lib/memory-format.js';
@@ -39,6 +39,8 @@ const MAX_FILE = 2 * 1024 * 1024;
39
39
  * 而 zk 默认不索引 org / txt —— 放进来只会得到「能直连、永远搜不到、还被 markdown 渲染坏」的页面。
40
40
  */
41
41
  const NOTE_EXT = /\.(?:md|markdown)$/i;
42
+ /** 首页「已归档(superseded)」一节最多列多少篇:与「最近更新 30 / 日记 10」一样有界,其余给总数 */
43
+ const ARCHIVE_PREVIEW = 50;
42
44
  /** 站内链接:查询串路由(宿主的 register 只支持 exact,拼不出 /note/:id) */
43
45
  function viewHref(params) {
44
46
  return `${VIEW}?${new URLSearchParams(params).toString()}`;
@@ -162,6 +164,21 @@ function tagCounts(notes) {
162
164
  function tagLinks(tags) {
163
165
  return tags.map((tag) => `<a href="${esc(viewHref({ p: 'tag', tag }))}">#${esc(tag)}</a>`).join(' ');
164
166
  }
167
+ /** zk 索引里的 type:老笔记没有就给一个可读的占位,不猜 */
168
+ function typeLabel(type) {
169
+ return type || '笔记';
170
+ }
171
+ /**
172
+ * 结构徽标:type 一律小字(原始 zk 值:source / concept / daily…,不翻译、不猜),
173
+ * status 只有非 active 才上徽标 —— 满屏 active 徽标等于没有徽标;
174
+ * superseded 单独一个 class,让它一眼能和 retired 区分开。
175
+ */
176
+ function noteBadges(note) {
177
+ const status = note.status && note.status !== 'active'
178
+ ? ` <span class="badge ${esc(note.status)}">${esc(note.status)}</span>`
179
+ : '';
180
+ return `<span class="type">${esc(typeLabel(note.type))}</span>${status}`;
181
+ }
165
182
  function noteTable(cfg, notes) {
166
183
  if (!notes.length)
167
184
  return '<p class="meta">没有笔记。</p>';
@@ -169,44 +186,83 @@ function noteTable(cfg, notes) {
169
186
  const rows = attachSummaries(cfg, notes).map((note) => {
170
187
  const date = localDate(note.modified || note.created) || '—';
171
188
  const brief = note.summary.length > 80 ? note.summary.slice(0, 80) + '…' : note.summary;
172
- return `<tr><td class="meta">${esc(date)}</td><td><a href="${esc(noteHref(note.path))}">${esc(note.title || note.path)}</a></td><td class="meta">${esc(brief || '—')}</td><td class="meta">${tagLinks(note.tags)}</td></tr>`;
189
+ const badges = noteBadges(note);
190
+ return `<tr><td class="meta">${esc(date)}</td><td><a href="${esc(noteHref(note.path))}">${esc(note.title || note.path)}</a>${badges}</td><td class="meta">${esc(brief || '—')}</td><td class="meta">${tagLinks(note.tags)}</td></tr>`;
173
191
  }).join('');
174
192
  return `<table><tr><th>日期</th><th>标题</th><th>摘要</th><th>标签</th></tr>${rows}</table>`;
175
193
  }
176
194
  function searchForm(value = '') {
177
195
  return `<form class="search" method="get" action="${VIEW}"><input type="search" name="q" value="${esc(value)}" placeholder="搜索标题、正文…" aria-label="搜索"><button type="submit">搜索</button></form>`;
178
196
  }
179
- /** 首页 / 标签页要「有没有扫全」;MAX_SCAN 是唯一的载入上限(不再用 2000 截断计数) */
197
+ /**
198
+ * 首页 / 标签页要「有没有扫全」;MAX_SCAN 是唯一的载入上限(不再用 2000 截断计数)。
199
+ * 连归档一起扫(includeArchived):被 supersede 的旧结论也是库的一部分,
200
+ * 排除口径吞掉它们,首页的「已归档(superseded)」一节就永远空着 ——
201
+ * 「最近更新」与标签计数在下面已经各自滤回 active,不会把归档混进去。
202
+ * 与 agent 的 `include_archived` 同一份口径:zk_* 查得回,人看的页面也看得见。
203
+ */
180
204
  async function loadScan(cfg) {
181
- return scanNotes(cfg);
205
+ return scanNotes(cfg, { includeArchived: true });
182
206
  }
183
207
  /** 只需要笔记的调用方(搜索兜底 / 记忆页反链解析) */
184
208
  async function loadAll(cfg) {
185
209
  return (await loadScan(cfg)).notes;
186
210
  }
187
- /** 搜索 / 标签走 zk;`q` 与 `tag` 同时给就是两个条件一起收(zk 按 AND 处理,不静默忽略其中一个) */
188
211
  async function pickNotes(cfg, opts) {
189
212
  if (opts.q || opts.tag) {
190
- return searchNotes(cfg, { query: opts.q, tags: opts.tag ? [opts.tag] : [], limit: opts.limit, sort: 'modified-desc' });
213
+ const notes = await searchNotes(cfg, {
214
+ query: opts.q,
215
+ tags: opts.tag ? [opts.tag] : [],
216
+ type: opts.type ? [opts.type] : [],
217
+ status: opts.status ? [opts.status] : [],
218
+ limit: opts.limit,
219
+ sort: 'modified-desc',
220
+ includeArchived: opts.includeArchived,
221
+ });
222
+ return { notes, atLeast: '' };
223
+ }
224
+ if (opts.type || opts.status) {
225
+ // 无 query 的 type / status 过滤也走 zk:JS 层过滤建立在全量扫描上,
226
+ // 归档目录的旧结论只有 includeArchived 才进得来(与标签过滤同一份口径)。
227
+ const notes = await searchNotes(cfg, {
228
+ type: opts.type ? [opts.type] : [],
229
+ status: opts.status ? [opts.status] : [],
230
+ limit: opts.limit,
231
+ sort: 'modified-desc',
232
+ includeArchived: opts.includeArchived,
233
+ });
234
+ return { notes, atLeast: '' };
191
235
  }
192
- return (await loadAll(cfg)).sort(byModified).slice(0, opts.limit);
236
+ const scan = await scanNotes(cfg, { includeArchived: opts.includeArchived, sort: 'modified-desc' });
237
+ return { notes: scan.notes.slice(0, opts.limit), atLeast: scan.completeness === 'complete' ? '' : '≥' };
193
238
  }
194
239
  // ── 页面 ──────────────────────────────────────────────────────────────
195
240
  async function handleHome(res, cfg) {
196
241
  const scan = await loadScan(cfg);
197
242
  const all = scan.notes;
198
243
  const atLeast = scan.completeness === 'complete' ? '' : '≥';
199
- const recent = [...all].sort(byModified).slice(0, 30);
200
- const journal = all.filter((note) => isUnderDir(note.path, cfg.dailyDir) || note.type === 'daily').sort(byModified).slice(0, 10);
201
- const tags = tagCounts(all);
244
+ const active = all.filter((note) => note.status !== 'superseded');
245
+ const archived = all.filter((note) => note.status === 'superseded');
246
+ const recent = [...active].sort(byModified).slice(0, 30);
247
+ // 归档只在自己的小节里露面:日记一节也滤回 active,别让一篇 superseded 的日记同时出现在两处
248
+ const journal = active.filter((note) => isUnderDir(note.path, cfg.dailyDir) || note.type === 'daily').sort(byModified).slice(0, 10);
249
+ // 这一节不能无界:10k 库的归档可能上万行,与旁边两节的口径不一致 —— 只列最近 ARCHIVE_PREVIEW 篇
250
+ const archivedRecent = [...archived].sort(byModified).slice(0, ARCHIVE_PREVIEW);
251
+ const tags = tagCounts(active);
202
252
  const body = [
203
253
  `<h1>${esc(cfg.active || 'zdiary')}</h1>`,
204
254
  searchForm(),
205
- `<p class="meta">${atLeast}${all.length} 篇笔记 · ${atLeast}${tags.length} 个标签 · 只读</p>`,
255
+ `<p class="meta">${atLeast}${all.length} 篇笔记(${atLeast}${active.length} 篇活跃 · ${atLeast}${archived.length} 篇已归档) · ${atLeast}${tags.length} 个标签 · 只读</p>`,
206
256
  '<h2>最近更新</h2>',
207
257
  noteTable(cfg, recent),
208
258
  '<h2>日记</h2>',
209
259
  noteTable(cfg, journal),
260
+ archived.length
261
+ ? '<h2>已归档(superseded)</h2>' + noteTable(cfg, archivedRecent) +
262
+ (archived.length > archivedRecent.length
263
+ ? `<p class="meta">共 ${atLeast}${archived.length} 篇已归档,这里只列最近 ${ARCHIVE_PREVIEW} 篇(按修改时间)。</p>`
264
+ : '')
265
+ : '',
210
266
  '<h2>标签</h2>',
211
267
  tags.length
212
268
  ? `<p class="tags">${tags.slice(0, 80).map(([tag, count]) => `<a href="${esc(viewHref({ p: 'tag', tag }))}">#${esc(tag)}</a><span class="count">${count}</span>`).join(' · ')}</p>`
@@ -265,7 +321,7 @@ function renderMemoryBody(body, linkFor) {
265
321
  return out.join('\n');
266
322
  }
267
323
  /**
268
- * 记忆页(P1-5 → D9):人的周审入口 —— 人格 / 用户 / 工作约定 / 记忆 / 周审五段 + 载荷预览。
324
+ * 记忆页:人的周审入口 —— 人格 / 用户 / 工作约定 / 记忆 / 周审五段 + 载荷预览。
269
325
  * 不走 `loadNote`:根目录 meta 被 `loadAll` 排除、也被 `loadNote` 明确拒绝;
270
326
  * 这里按常量直接读盘,再复用渲染层的转义与双链白名单。
271
327
  * 载荷预览只转义展示(与 zk_context 同源),不提供编辑 —— 写仍然只走 zk_* / 编辑器。
@@ -382,33 +438,65 @@ async function handleMemory(res, cfg) {
382
438
  ].join('\n');
383
439
  sendHtml(res, 200, shell(cfg, '记忆', body));
384
440
  }
385
- async function handleTags(res, cfg) {
441
+ /** 结构过滤的取值:type 跟 zk_new 的目录约定走,status 只有两态 */
442
+ const TYPE_VALUES = ['concept', 'source', 'daily', 'meeting', 'person', 'topic'];
443
+ const STATUS_VALUES = ['active', 'superseded'];
444
+ /** 「type=source · status=superseded」这样的可读串;两个都空就是「不过滤」 */
445
+ function structureSummary(type, status) {
446
+ return [type ? `type=${type}` : '', status ? `status=${status}` : ''].filter(Boolean).join(' · ') || '不过滤';
447
+ }
448
+ /** type / status 过滤表单:纯 GET、无 JS,select 的当前值回显 */
449
+ function structureForm(current, tag) {
450
+ const hidden = tag !== null
451
+ ? `<input type="hidden" name="p" value="tag"><input type="hidden" name="tag" value="${esc(tag)}">`
452
+ : '<input type="hidden" name="p" value="tags">';
453
+ const options = (values, picked, empty) => `<option value=""${picked ? '' : ' selected'}>${esc(empty)}</option>` +
454
+ values.map((v) => `<option value="${v}"${v === picked ? ' selected' : ''}>${esc(v)}</option>`).join('');
455
+ return `<form class="search" method="get" action="${VIEW}">${hidden}` +
456
+ `<select name="type" aria-label="按 type 过滤">${options(TYPE_VALUES, current.type, '全部 type')}</select> ` +
457
+ `<select name="status" aria-label="按 status 过滤">${options(STATUS_VALUES, current.status, '全部 status')}</select> ` +
458
+ '<button type="submit">过滤</button></form>';
459
+ }
460
+ async function handleTags(res, cfg, type, status) {
386
461
  const scan = await loadScan(cfg);
387
462
  const notes = scan.notes;
388
463
  const atLeast = scan.completeness === 'complete' ? '' : '≥';
389
- const tags = tagCounts(notes);
464
+ const active = notes.filter((note) => note.status !== 'superseded');
465
+ const archived = notes.filter((note) => note.status === 'superseded');
466
+ const tags = tagCounts(active);
390
467
  const body = [
391
468
  `<p class="crumb"><a href="${VIEW}">首页</a> / 标签</p>`,
392
469
  '<h1>标签</h1>',
393
- `<p class="meta">${atLeast}${tags.length} 个标签 · ${atLeast}${notes.length} 篇笔记` +
470
+ `<p class="meta">${atLeast}${tags.length} 个标签 · ${atLeast}${notes.length} 篇笔记(${atLeast}${active.length} 篇活跃 · ${atLeast}${archived.length} 篇已归档)` +
394
471
  (scan.completeness === 'complete' ? '' : `(只扫描了前 ${scan.limit} 篇)`) + '</p>',
472
+ structureForm({ type, status }, null),
473
+ (type || status)
474
+ ? `<p class="meta">过滤:${esc(structureSummary(type, status))} · <a href="${esc(viewHref({ p: 'tags' }))}">清除</a></p>` +
475
+ noteTable(cfg, await pickNotes(cfg, { type, status, limit: 200, includeArchived: true }).then((picked) => picked.notes))
476
+ : '',
395
477
  tags.length
396
478
  ? `<p class="tags">${tags.map(([tag, count]) => `<a href="${esc(viewHref({ p: 'tag', tag }))}">#${esc(tag)}</a><span class="count">${count}</span>`).join(' · ')}</p>`
397
479
  : '<p class="meta">还没有标签。</p>',
398
480
  ].join('\n');
399
481
  sendHtml(res, 200, shell(cfg, '标签', body));
400
482
  }
401
- async function handleTag(res, cfg, tag) {
483
+ async function handleTag(res, cfg, tag, type, status) {
402
484
  if (!tag) {
403
485
  noticePage(res, cfg, '标签', '没给标签名:从首页或标签页点一个进来。', 400);
404
486
  return;
405
487
  }
406
- const notes = await searchNotes(cfg, { tags: [tag], limit: 200, sort: 'modified-desc' });
488
+ // 归档旧结论也用同一个标签查回(include_archived):agent 用 zk_search 的 include_archived
489
+ // 能查回被 supersede 的结论,这一页不再被排除口径整个吞掉。
490
+ const picked = await pickNotes(cfg, { tag, type, status, limit: 200, includeArchived: true });
491
+ const notes = picked.notes;
492
+ const archivedCount = notes.filter((note) => inArchive(cfg, note.path)).length;
407
493
  const body = [
408
494
  `<p class="crumb"><a href="${VIEW}">首页</a> / <a href="${esc(viewHref({ p: 'tags' }))}">标签</a></p>`,
409
495
  `<h1>#${esc(tag)}</h1>`,
410
- `<p class="meta">${notes.length} 篇(最多 200 篇)</p>`,
411
- noteTable(cfg, notes),
496
+ `<p class="meta">${notes.length} 篇(最多 200 篇${archivedCount ? `,其中归档 ${archivedCount} 篇` : ''})</p>` +
497
+ structureForm({ type, status }, tag) +
498
+ ((type || status) ? `<p class="meta">过滤:${esc(structureSummary(type, status))}</p>` : '') +
499
+ noteTable(cfg, notes),
412
500
  ].join('\n');
413
501
  sendHtml(res, 200, shell(cfg, `#${tag}`, body));
414
502
  }
@@ -476,17 +564,34 @@ async function handleNote(res, cfg, rel) {
476
564
  let backlinks = [];
477
565
  let backlinksTruncated = false;
478
566
  try {
479
- // 按篇反查(plan §0.5.1 结论 3):打开一篇笔记不该为全库建图(10k 要 26–31 s)
567
+ // 按篇反查:打开一篇笔记不该为全库建图(10k 要 26–31 s)
480
568
  const found = await backlinksOf(cfg, loaded.rel);
481
569
  backlinks = found.notes.sort((a, b) => a.title.localeCompare(b.title));
482
570
  backlinksTruncated = found.truncated;
483
571
  }
484
572
  catch { /* 反链读不出来就不显示 */ }
573
+ let outlinks = [];
574
+ let outlinksTruncated = false;
575
+ try {
576
+ // 出链:同一套按篇反查(--linked-by),归档目标也列出来 ——
577
+ // 指向被 supersede 旧结论的边,正是「为什么换了结论」的线索,不该因为目标在归档目录就消失。
578
+ const found = await outlinksOf(cfg, loaded.rel, { includeArchived: true });
579
+ outlinks = found.notes.sort((a, b) => a.title.localeCompare(b.title));
580
+ outlinksTruncated = found.truncated;
581
+ }
582
+ catch { /* 出链读不出来就不显示 */ }
583
+ // 被 supersede 的笔记:把 supersede 写下的「被谁取代 / 为什么」读出来(frontmatter 一行,不再跑 zk)
584
+ let supersededBy = null;
585
+ let supersedeReason = null;
586
+ if (loaded.doc.status === 'superseded') {
587
+ supersededBy = String(loaded.doc.metadata['superseded-by'] ?? '') || null;
588
+ supersedeReason = String(loaded.doc.metadata['supersede-reason'] ?? '') || null;
589
+ }
485
590
  const content = loaded.doc.content.length > MAX_CONTENT
486
591
  ? loaded.doc.content.slice(0, MAX_CONTENT)
487
592
  : loaded.doc.content;
488
593
  const truncated = content.length < loaded.doc.content.length;
489
- // 时间轴警告(计划 §2 D3):只在日记页出现,正文照原 markdown 渲染(空块保持空 h3)。
594
+ // 时间轴警告:只在日记页出现,正文照原 markdown 渲染(空块保持空 h3)。
490
595
  // 不受 zk_lint 的 90 天窗口限制:打开哪篇查哪篇。
491
596
  const timeline = isUnderDir(loaded.rel, cfg.dailyDir)
492
597
  ? timelineIssues(loaded.doc.content, 'auto')
@@ -498,12 +603,22 @@ async function handleNote(res, cfg, rel) {
498
603
  '</details></div>',
499
604
  ].join('\n');
500
605
  const body = [
501
- `<p class="crumb"><a href="${VIEW}">首页</a> / ${esc(loaded.doc.type || '笔记')}</p>`,
606
+ `<p class="crumb"><a href="${VIEW}">首页</a> / ${esc(typeLabel(loaded.doc.type))}</p>`,
502
607
  `<h1>${esc(loaded.doc.title || loaded.rel)}</h1>`,
503
- `<p class="meta">${esc(localDate(loaded.doc.created) || '—')} · ${loaded.doc.words} 词${loaded.doc.tags.length ? ' · ' + tagLinks(loaded.doc.tags) : ''}</p>`,
608
+ `<p class="meta">${noteBadges(loaded.doc)} · ${esc(localDate(loaded.doc.created) || '—')} · ${loaded.doc.words} 词${loaded.doc.tags.length ? ' · ' + tagLinks(loaded.doc.tags) : ''}</p>`,
609
+ (supersededBy || supersedeReason)
610
+ ? `<p class="notice">已废弃(superseded):${supersededBy ? `被 ${esc(supersededBy)} 取代` : '没有写被谁取代'}${supersedeReason ? ` —— ${esc(supersedeReason)}` : ''}</p>`
611
+ : '',
504
612
  timelineNotice,
505
613
  truncated ? `<p class="notice">正文超过 ${MAX_CONTENT} 字符,这里只显示前 ${MAX_CONTENT} 字符。</p>` : '',
506
614
  `<article>${renderMarkdown(content, { linkFor, skipFirstH1: true })}</article>`,
615
+ '<h2>出链</h2>',
616
+ outlinks.length
617
+ ? `<ul>${outlinks.slice(0, 100).map((note) => `<li><a href="${esc(noteHref(note.path))}">${esc(note.title || note.path)}</a>${noteBadges(note)}</li>`).join('')}</ul>` +
618
+ (outlinksTruncated || outlinks.length > 100
619
+ ? `<p class="meta">${outlinksTruncated ? '出链超过 200 条' : `共 ${outlinks.length} 条`},这里只列前 100 条。</p>`
620
+ : '')
621
+ : '<p class="meta">这篇没有链到其它笔记。</p>',
507
622
  '<h2>反链</h2>',
508
623
  backlinks.length
509
624
  ? `<ul>${backlinks.slice(0, 100).map((note) => `<li><a href="${esc(noteHref(note.path))}">${esc(note.title || note.path)}</a></li>`).join('')}</ul>` +
@@ -526,6 +641,10 @@ async function handleView(req, res) {
526
641
  const p = url.searchParams.get('p') ?? '';
527
642
  const q = (url.searchParams.get('q') ?? '').trim();
528
643
  const tag = (url.searchParams.get('tag') ?? '').trim();
644
+ // 结构过滤:type / status 都是纯 GET 查询串(无 JS,Web 1.0 口径);
645
+ // 未知值不猜:原样传给 zk 的 JS 层过滤,匹配不到就是空结果,页面照常可读。
646
+ const type = (url.searchParams.get('type') ?? '').trim();
647
+ const status = (url.searchParams.get('status') ?? '').trim();
529
648
  if (!st.ready) {
530
649
  noticePage(res, st.cfg, '只读视图', st.reason);
531
650
  return;
@@ -536,9 +655,9 @@ async function handleView(req, res) {
536
655
  if (p === 'memory')
537
656
  return await handleMemory(res, st.cfg);
538
657
  if (p === 'tags')
539
- return await handleTags(res, st.cfg);
658
+ return await handleTags(res, st.cfg, type, status);
540
659
  if (p === 'tag')
541
- return await handleTag(res, st.cfg, tag);
660
+ return await handleTag(res, st.cfg, tag, type, status);
542
661
  if (q)
543
662
  return await handleSearch(res, st.cfg, q);
544
663
  return await handleHome(res, st.cfg);
@@ -582,9 +701,13 @@ async function handleApiNotes(req, res) {
582
701
  }
583
702
  const q = (url.searchParams.get('q') ?? '').trim();
584
703
  const tag = (url.searchParams.get('tag') ?? '').trim();
704
+ const type = (url.searchParams.get('type') ?? '').trim();
705
+ const status = (url.searchParams.get('status') ?? '').trim();
585
706
  try {
586
- const notes = await pickNotes(st.cfg, { q, tag, limit: limitOf(url) });
587
- json(res, 200, { ok: true, count: notes.length, notes: notes.map(publicNote) });
707
+ // includeArchived 跟着过滤条件走:归档目录默认被 `-x` 排除,`?status=superseded` / 归档里的
708
+ // `?type=source` 不带它就是恒空(静默空结果)。默认列表保持「不含归档」的既有口径不变。
709
+ const picked = await pickNotes(st.cfg, { q, tag, type, status, limit: limitOf(url), includeArchived: Boolean(type || status) });
710
+ json(res, 200, { ok: true, count: picked.notes.length, notes: picked.notes.map(publicNote) });
588
711
  }
589
712
  catch (err) {
590
713
  json(res, 503, { ok: false, error: publicMessage(err) });
@@ -646,7 +769,9 @@ async function handleFeed(req, res) {
646
769
  }
647
770
  let notes;
648
771
  try {
649
- notes = (await loadAll(st.cfg)).sort(byModified).slice(0, 30);
772
+ // RSS 是「最近更新」的订阅面,与首页同一份口径:supersede 过的旧结论不进 feed。
773
+ // 否则它们会被 supersede 时的改写顶到最前面,把真正的更新挤下去(首页已滤回 active)。
774
+ notes = (await loadAll(st.cfg)).filter((note) => note.status !== 'superseded').sort(byModified).slice(0, 30);
650
775
  }
651
776
  catch (err) {
652
777
  sendText(res, 503, publicMessage(err));
@@ -52,6 +52,9 @@ const CSS = [
52
52
  'form.search{margin:12px 0}form.search input{font:inherit;padding:3px 6px;width:min(100%,360px);border:1px solid #999}',
53
53
  'form.search button{font:inherit;padding:3px 10px;margin-left:4px}',
54
54
  '.wikilink{color:#777;border-bottom:1px dotted #999}',
55
+ '.type{color:#777;font-size:12px;margin-left:6px}',
56
+ '.badge{display:inline-block;margin-left:6px;padding:0 5px;border:1px solid #999;border-radius:3px;font-size:11px;color:#555;background:#f3f3f3}',
57
+ '.badge.superseded{border-color:#d9a300;color:#8a6100;background:#fffbe6}',
55
58
  'footer{margin-top:26px;color:#666;font-size:12px}',
56
59
  '.crumb{font-size:13px;color:#666}',
57
60
  '@media print{body{max-width:none;font-size:12pt}nav,form.search,footer{display:none}a{color:#000;text-decoration:none}}',