Skip to content

Commit 2eec7c4

Browse files
fix: sync the page title regarding the title config (#2478)
Co-authored-by: Luffy <[email protected]>
1 parent 676f5f8 commit 2eec7c4

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Diff for: src/core/event/index.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,17 @@ export function Events(Base) {
299299
* @void
300300
*/
301301
onRender() {
302+
const { name } = this.config;
302303
const currentPath = this.router.toURL(this.router.getCurrentPath());
303-
const currentTitle = dom.find(
304-
`.sidebar a[href='${currentPath}']`,
305-
)?.innerText;
304+
const currentSection = dom
305+
.find(`.sidebar a[href='${currentPath}']`)
306+
?.getAttribute('title');
307+
308+
const currentTitle = name
309+
? currentSection
310+
? `${currentSection} - ${name}`
311+
: name
312+
: currentSection;
306313

307314
// Update page title
308315
dom.$.title = currentTitle || this.#title;

Diff for: src/plugins/search/component.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ function doSearch(value) {
4949

5050
let html = '';
5151
matches.forEach((post, i) => {
52+
const title = (post.title || '').replace(/<[^>]+>/g, '');
5253
html += /* html */ `
5354
<div class="matching-post" aria-label="search result ${i + 1}">
54-
<a href="${post.url}">
55+
<a href="${post.url}" title="${title}">
5556
<p class="title clamp-1">${post.title}</p>
5657
<p class="content clamp-2">${post.content}</p>
5758
</a>

0 commit comments

Comments
 (0)