docsify icon indicating copy to clipboard operation
docsify copied to clipboard

logo in sidebar links to landing page instead of site homepage

Open shawaj opened this issue 4 years ago • 7 comments

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

shawaj avatar Jun 06 '21 03:06 shawaj

It seems that routerMode: 'history' is causing the problem

sy-records avatar Jun 06 '21 05:06 sy-records

@sy-records Thanks, and how can we disable it?

salmanfarisvp avatar Jun 06 '21 14:06 salmanfarisvp

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.

julien-boudry avatar Jan 09 '23 15:01 julien-boudry

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 avatar Jan 17 '23 14:01 julien-boudry

👌

shawaj avatar Jan 17 '23 15:01 shawaj

@julien-boudry great fix. However I had to use the afterEach hook or the logo link would keep changing.

AlejandroMut avatar Jan 31 '23 16:01 AlejandroMut

@AlejandroMut Don't have issues with mounted hook, example here: https://www.condorcet.io But both must work, afterEach is just more aggressive.

julien-boudry avatar Jan 31 '23 17:01 julien-boudry