mirror of
https://gitee.com/docsifyjs/docsify.git
synced 2024-11-29 18:48:14 +08:00
fix: sync the page title regarding the title config (#2478)
Co-authored-by: Luffy <52o@qq52o.cn>
This commit is contained in:
parent
676f5f8842
commit
2eec7c4884
@ -299,10 +299,17 @@ export function Events(Base) {
|
||||
* @void
|
||||
*/
|
||||
onRender() {
|
||||
const { name } = this.config;
|
||||
const currentPath = this.router.toURL(this.router.getCurrentPath());
|
||||
const currentTitle = dom.find(
|
||||
`.sidebar a[href='${currentPath}']`,
|
||||
)?.innerText;
|
||||
const currentSection = dom
|
||||
.find(`.sidebar a[href='${currentPath}']`)
|
||||
?.getAttribute('title');
|
||||
|
||||
const currentTitle = name
|
||||
? currentSection
|
||||
? `${currentSection} - ${name}`
|
||||
: name
|
||||
: currentSection;
|
||||
|
||||
// Update page title
|
||||
dom.$.title = currentTitle || this.#title;
|
||||
|
@ -49,9 +49,10 @@ function doSearch(value) {
|
||||
|
||||
let html = '';
|
||||
matches.forEach((post, i) => {
|
||||
const title = (post.title || '').replace(/<[^>]+>/g, '');
|
||||
html += /* html */ `
|
||||
<div class="matching-post" aria-label="search result ${i + 1}">
|
||||
<a href="${post.url}">
|
||||
<a href="${post.url}" title="${title}">
|
||||
<p class="title clamp-1">${post.title}</p>
|
||||
<p class="content clamp-2">${post.content}</p>
|
||||
</a>
|
||||
|
Loading…
Reference in New Issue
Block a user