mirror of
https://github.com/docsifyjs/docsify.git
synced 2026-10-17 04:31:18 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user