logo in sidebar links to landing page instead of site homepage
Bug Report
Steps to reproduce
When using a logo instead of a "site name" in the top left of the sidebar, the logo doesn't link to the site homepage, but links to the page you landed on the website from.
If you set a nameLink parameter, this does not fix the issue either.
What is current behaviour
For example, if you land on the website via websitename.com then regardless of where you browse to from then on, the website links the logo to the home page.
However, if you arrive on the website directly to websitename.com/examplepage then from that point onwards, regardless of where you browse to on the site, the logo links to the landing page you arrived on - i.e. websitename.com/examplepage in this case.
What is the expected behaviour
The logo should always link to either the home page of the site (default) or to the nameLink parameter specified in the index.html file
Other relevant information
-
[x] Bug does still occur when all/other plugins are disabled?
-
Your OS:
-
Node.js version:
-
npm/yarn version:
-
Browser version:
-
Docsify version: 4.12.1
-
Docsify plugins:
Relates to https://github.com/NebraLtd/Helium-Guides/issues/82
Please create a reproducible sandbox
N/A
Mention the docsify version in which this bug was not present (if any)
N/A
It seems that routerMode: 'history' is causing the problem
@sy-records Thanks, and how can we disable it?
The same problem, can be reproduced here: https://www.condorcet.io/3.AsPhpLibrary/5.Votes/1.AddVotes I confirmed that it is related to the history mod.
A simple fix with a plugin:
window.$docsify = {
plugins: [
function docsifyFixLogoLink(hook, vm) {
hook.mounted(function () {
const logoLinkTag = document.querySelector(`a.app-name-link`);
logoLinkTag.setAttribute('href', '/');
});
}
]
}
@shawaj @salmanfarisvp
👌
@julien-boudry great fix. However I had to use the afterEach hook or the logo link would keep changing.
@AlejandroMut Don't have issues with mounted hook, example here: https://www.condorcet.io
But both must work, afterEach is just more aggressive.