From 978b2415ce46cbb6911aeae7ae92091c0f0afb11 Mon Sep 17 00:00:00 2001 From: tianma-if Date: Thu, 22 Oct 2026 11:25:47 +0800 Subject: [PATCH] fix(web): hide the note title from the first PDF page header --- apps/web/src/styles/note-print.css | 8 ++++++++ apps/web/src/styles/note-print.test.mjs | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 apps/web/src/styles/note-print.test.mjs diff --git a/apps/web/src/styles/note-print.css b/apps/web/src/styles/note-print.css index 11ff9871..9669e54c 100644 --- a/apps/web/src/styles/note-print.css +++ b/apps/web/src/styles/note-print.css @@ -17,6 +17,14 @@ } } +/* The note title is already the first-page heading. A running header there + repeats the same text above it. Later pages still carry the title. */ +@page :first { + @top-center { + content: none; + } +} + * { box-sizing: border-box; } diff --git a/apps/web/src/styles/note-print.test.mjs b/apps/web/src/styles/note-print.test.mjs new file mode 100644 index 00000000..c4d29522 --- /dev/null +++ b/apps/web/src/styles/note-print.test.mjs @@ -0,0 +1,23 @@ +import { readFileSync } from "node:fs"; +import { describe, expect, test } from "bun:test"; + +const css = readFileSync(new URL("./note-print.css", import.meta.url), "utf8"); + +const pageRule = (selector) => { + const marker = `@page${selector} {`; + const start = css.indexOf(marker); + expect(start).toBeGreaterThanOrEqual(0); + const end = css.indexOf("\n}", start); + return css.slice(start, end); +}; + +describe("note print running header", () => { + test("repeats the note title from the second page onward", () => { + expect(pageRule("")).toContain("content: string(edgeever-note-title)"); + expect(css).toContain("string-set: edgeever-note-title content(text)"); + }); + + test("leaves the first page header empty so it does not repeat the title", () => { + expect(pageRule(" :first")).toMatch(/@top-center\s*\{[^}]*content:\s*none;/s); + }); +});