Wiki Phase 3: internal links, backlinks, and tags

Connectivity phase of the wiki upgrade (see WIKI_UPGRADE.md).

Schema (additive new tables): wiki_tags, wiki_page_tags, wiki_links.

Internal links & backlinks:
- new wiki.links.js parses a saved body for /wiki/<slug> (and data-wiki-slug)
  targets; wiki_links is rebuilt on every save
- article shows a "Linked from" section (published backlinks) and renders
  links to non-existent pages as red links (server returns missing_links)
- editor gains an internal-link picker listing existing pages

Tags:
- pages accept a tags[] array; tags upsert on save, page tag-set is replaced,
  and orphaned tags are auto-pruned (on save and delete)
- public/admin list filter by ?tag=; /wiki/tags lists tags with published counts
- article shows tag chips; the index has a flat tag-filtered view; editor has a
  comma-separated tags field

Verified end-to-end: A->B backlink appears, red link detected, link index
rebuilds on edit, tag filtering + chips + pruning all work.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-27 11:25:15 -05:00
parent 4a7dbf0085
commit 7c081ae749
15 changed files with 516 additions and 70 deletions

View File

@@ -314,10 +314,10 @@ button[disabled] {
/* ===== Rich text editor (TipTap) ===== */
.rte {
position: relative;
border: 1px solid var(--line);
border-radius: 8px;
background: var(--bg);
overflow: hidden;
}
.rte:focus-within {
border-color: var(--accent);
@@ -380,6 +380,72 @@ button[disabled] {
color: var(--dim);
pointer-events: none;
}
/* Internal-link picker popover */
.rte-linkmenu {
position: absolute;
z-index: 20;
top: 50px;
left: 10px;
width: min(360px, calc(100% - 20px));
padding: 10px;
border: 1px solid var(--line);
border-radius: 8px;
background: var(--panel-a);
box-shadow: var(--shadow-card);
}
.rte-linkmenu-list {
margin-top: 8px;
max-height: 220px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 2px;
}
.rte-linkmenu-item {
display: flex;
justify-content: space-between;
align-items: baseline;
gap: 12px;
padding: 7px 9px;
border: none;
border-radius: 6px;
background: transparent;
color: var(--text);
font-family: var(--sans);
font-size: 0.88rem;
text-align: left;
cursor: pointer;
}
.rte-linkmenu-item:hover {
background: var(--blue);
color: var(--ink);
}
.rte-linkmenu-slug {
color: var(--dim);
font-family: ui-monospace, Menlo, monospace;
font-size: 0.76rem;
}
/* ===== Wiki connectivity (tags + red links) ===== */
.wiki-tag {
display: inline-block;
padding: 3px 10px;
border: 1px solid var(--line);
border-radius: 999px;
background: rgba(127, 153, 189, 0.1);
color: var(--accent);
font-family: var(--sans);
font-size: 0.78rem;
text-decoration: none;
}
.wiki-tag:hover {
border-color: var(--accent);
background: var(--blue);
}
.prose a.wiki-red-link {
color: #d98b84;
border-bottom: 1px dotted #d98b84;
}
/* ===== Admin tables ===== */
.adm-table {