Skip to content

Commit 0c85319

Browse files
committed
fix(workbench): strip wiki frontmatter in the reader (no leading rule / junk)
GET /api/v1/page serves pages verbatim, so every concept/entity/summary page's OKF `--- … ---` frontmatter leaked into the reader as junk metadata lines — and, now that MarkdownView renders `---` as an <hr>, as a horizontal rule at the very top. Strip a leading frontmatter block before rendering (reader only; chat answers carry no frontmatter and are untouched). Second-review follow-up. Claude-Session: https://claude.ai/code/session_01XMxbhmAkxxVV8CFWCZDBaG
1 parent ae8523c commit 0c85319

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

frontend/src/pages/KbDetail.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ import KbSettingsSheet from '@/components/KbSettingsSheet'
1414
import { useAnimatedSwitch } from '@/hooks/useAnimatedSwitch'
1515
import { cn } from '@/lib/utils'
1616

17+
/** Strip a leading YAML frontmatter block (`--- … ---`) from a raw wiki page.
18+
* Pages are served verbatim by `GET /api/v1/page`, so the OKF frontmatter
19+
* would otherwise render in the reader as junk metadata lines — and, now that
20+
* MarkdownView renders thematic breaks, its `---` delimiters as horizontal
21+
* rules. No-op when there is no leading frontmatter. Only the reader strips it;
22+
* chat answers (which carry no frontmatter) go through MarkdownView untouched. */
23+
function stripFrontmatter(md: string): string {
24+
return md.replace(/^---\r?\n[\s\S]*?\r?\n---[ \t]*\r?\n?/, '')
25+
}
26+
1727
/** One selected wiki page, derived from its `<type>/<name>` path. */
1828
interface SelectedPage {
1929
/** Path passed to `/api/v1/page` (relative to `wiki/`). */
@@ -121,7 +131,7 @@ export default function KbDetail() {
121131
getPage(id, path)
122132
.then((r) => {
123133
if (cancelled) return
124-
setPage({ path, content: r.content })
134+
setPage({ path, content: stripFrontmatter(r.content) })
125135
setPageError(null)
126136
})
127137
.catch((e) => {

0 commit comments

Comments
 (0)