fix: sync the page title regarding the title config by Koooooo-7 · Pull Request #2478 · docsifyjs/docsify

Summary

Currently, on the v5 changes, each headings/links on the sidebar has the title via #addTextAsTitleAttribute.

#addTextAsTitleAttribute(cssSelector) {

After the event refactor, the page title update function changed, especially the search page title.


Example from our site.
v4:
On the main content load the page title such as Configuration, no matter you switch the sections to Configuration.
or directly jump to its sub headings configuration?id=alias.

The page title is always `Configuration`.

v5 as-is:
On the main content load the page title such as Configuration, switch the sections to Configuration. (same to v4 )
⚠️ directly jump to its sub headings configuration?id=alias via the URL,it will update the page title to sub title (alias) instead.
⚠️ On the search function, when clicks the search result, it comes to the mess innerText as page title instead.

The behavior for the sidebar headings for main content, I think it makes sense to indicate the specific target and respect the title.
So, I fix the search problem via a consistent way that all retrieve page title from to the title attribute also.
Now, it will use the ${name} - ${title} as the page title, if no name config, use title directly.

Related issue, if any:

What kind of change does this PR introduce?

Bugfix

For any code change,

  • Related documentation has been updated, if needed
  • Related tests have been added or updated, if needed

Does this PR introduce a breaking change?

Yes
No

No

Tested in the following browsers:

  • Chrome
  • Firefox
  • Safari
  • Edge