docsifyjs / docsify

🃏 A magical documentation site generator.
https://docsify.js.org
MIT License
27.78k stars 5.68k forks source link

fix: sync the page title regarding the title config #2478

Closed Koooooo-7 closed 3 months ago

Koooooo-7 commented 3 months ago

Summary

Currently, on the v5 changes, each headings/links on the sidebar has the title via #addTextAsTitleAttribute. https://github.com/docsifyjs/docsify/blob/42f25482fa1ea6ec666800145f6da33e9119aa8c/src/core/render/index.js#L20

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 ) :warning: 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,

Does this PR introduce a breaking change?

Yes No

No

Tested in the following browsers:

vercel[bot] commented 3 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docsify-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 11, 2024 2:55am
trusktr commented 3 months ago

Hmm, I see yeah it is inconsistent depending how you land on the page. Clicking on your link, the title is alias, but if you navigate to the page from inside Docsify, the title is Configuration.

Also I think that it would be better for the title to be Docsify - Page for each page whre Page is the name of the page, or similar. F.e. Docsify - Configuration, Docsify - Quick start, etc.

Koooooo-7 commented 3 months ago

Hmm, I see yeah it is inconsistent depending how you land on the page. Clicking on your link, the title is alias, but if you navigate to the page from inside Docsify, the title is Configuration.

Also I think that it would be better for the title to be Docsify - Page for each page whre Page is the name of the page, or similar. F.e. Docsify - Configuration, Docsify - Quick start, etc.

Yea, It makes sense that we could concat the name of the site as a prefix. I gonna update it.


update.