vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
13.17k stars 2.12k forks source link

Regression: Router breaks navigation to custom home URL #3264

Closed elringus closed 10 months ago

elringus commented 11 months ago

Describe the bug

When using custom home page and themeConfig.logoLink is set to that paget, after any navigation happens in the docs, clicking the logo loads 404 page. See video below for a demo.

https://github.com/vuejs/vitepress/assets/2056864/69241914-58ab-4400-9013-7d9379cb4c14

Reproduction

Not sure how reproduce this in a sandbox (the docs have to be deployed), but here are the sources of the demo above: https://github.com/naninovel/Documentation/tree/master/docs

Notice, that the bug only kicks in after some navigation happens in the docs; eg, it won't reproduce if you open the docs and immediately click the logo (in this case the home page will load correctly).

Expected behavior

Clicking on logo should load custom home page.

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (16) x64 Intel(R) Core(TM) i7-6900K CPU @ 3.20GHz
    Memory: 52.30 GB / 63.92 GB
  Binaries:
    Node: 20.5.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 9.6.6 - C:\Program Files\nodejs\npm.CMD
    pnpm: 7.29.3 - C:\ProgramData\chocolatey\bin\pnpm.EXE
  Browsers:
    Chrome: 119.0.6045.160
    Edge: Spartan (44.19041.3636.0), Chromium (119.0.2151.72)

Additional context

No response

Validations

brc-dd commented 11 months ago

This was likely fixed in vitepress 1.0.0-rc.29. Can you try updating your deps.

elringus commented 11 months ago

I've actually tested this on the latest rc.31 (in a branch).

Just to make sure I've updated to 31 on the main branch and deployed — still the same issue.

zonemeen commented 11 months ago

Try changing the logoLink: "https://naninovel.com" in your configuration to logoLink: "//naninovel.com" or logoLink: "naninovel.com".

elringus commented 11 months ago

Try changing the logoLink: "https://naninovel.com" in your configuration to logoLink: "//naninovel.com" or logoLink: "naninovel.com".

Didn't work: naniovel.com in logo link redirects to https://naninovel.com/guide/naninovel.com when logo is clicked.

Notice, that I'm using custom ./docs/public/index.html and don't have ./docs/index.md. Previously it worked fine on deployment and in preview, but in dev it was returning 404 (which I didn't mind); I remember in some of the recent patches you've mentioned something about making router both in dev and preview work the same, may this is where it regressed (can't find the exact release to test).

zonemeen commented 11 months ago

Is it still not working if you set it to logoLink: "//naninovel.com"?

The temporary workaround I can think of is this.🤔

elringus commented 11 months ago

Is it still not working if you set it to logoLink: "//naninovel.com"?

Nope, still the same behavior.

brc-dd commented 10 months ago

Use this in next version:

    logoLink: {
      link: '/',
      target: '_self'
    },

It should work fine in dev too.