fix: strip HTML tags from config.name when setting page title (#2690)

The `name` config option can contain HTML markup (e.g. `<img>` tags) for
rendering a logo in the sidebar. However, this raw HTML was being used
directly in `document.title`, causing browser tabs to show markup like
`<img src="logo.png">My Site - Page Title`.

Strip HTML tags from `name` before using it in the page title so that
only the plain text content appears in the browser tab.

Fixes #2610

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Bowl42
2026-03-04 21:08:53 +08:00
committed by GitHub
parent f4c37e0ada
commit 0cfee34dbc
+4 -3
View File
@@ -329,10 +329,11 @@ export function Events(Base) {
.find(`.sidebar a[href='${currentPath}']`)
?.getAttribute('title');
const currentTitle = name
const plainName = name ? name.replace(/<[^>]+>/g, '').trim() : name;
const currentTitle = plainName
? currentSection
? `${currentSection} - ${name}`
: name
? `${currentSection} - ${plainName}`
: plainName
: currentSection;
// Update page title