vuepress / ecosystem

Official plugins and themes for VuePress2
https://ecosystem.vuejs.press
MIT License
20 stars 26 forks source link

[Bug report] navbar/sidebar no longer respects relative paths for title generation #110

Closed lifehackerhansol closed 1 month ago

lifehackerhansol commented 2 months ago

Description

On 2rc0 and prior versions, it was possible to use relative paths as a source for navbar/sidebar's text generation as described here:

This is broken somewhere between 2rc0 and 2rc9; it doesn't throw any warning or error if a title isn't found, it just sets to <page>.html.

In our case, it's not exactly feasible to use absolute paths, as this would break our translation platform, Crowdin, in a configuration where the default language is at the root of the site and the translated languages are in a subdirectory.

Reproduction

https://github.com/lifehackerhansol/dsi.cfw.guide/tree/vuepress-2rc9, with submodule https://github.com/lifehackerhansol/emiyl-theme-2

Used Package Manager

npm

System Info

$ ./node_modules/.bin/vuepress info

  System:
    OS: Linux 6.5 Ubuntu 23.10 23.10 (Mantic Minotaur)
    CPU: (16) x64 AMD Ryzen 7 3800X 8-Core Processor
    Memory: 116.61 GB / 125.71 GB
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    Yarn: Not Found
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
    pnpm: Not Found
    bun: Not Found
  Utilities:
    Git: 2.40.1 - /usr/bin/git
  Browsers:
    Chrome: Not Found
  npmPackages:
    @vuepress/bundler-vite:  2.0.0-rc.9 
    @vuepress/bundler-webpack: ^2.0.0-rc.9 => 2.0.0-rc.9 
    @vuepress/cli:  2.0.0-rc.9 
    @vuepress/client:  2.0.0-rc.9 
    @vuepress/core:  2.0.0-rc.9 
    @vuepress/markdown:  2.0.0-rc.9 
    @vuepress/shared:  2.0.0-rc.9 
    @vuepress/utils:  2.0.0-rc.9 
    vue:  3.4.25 
    vue-router:  4.3.2 
    vuepress: 2.0.0-rc.9 => 2.0.0-rc.9
Mister-Hope commented 2 months ago

Why can navbar and sidebar be relative path?

The whole site is using one navbar, and in.most cases you are expecting to set an absolute path, so is sidebar. Though you could set different sidebar for each folder, we are expecting a sidebar to not be sensitive with current page, to avoid issues.

Futher more, you can get relative path title, like what we are doing at PageNav (prev and next link)

lifehackerhansol commented 2 months ago

I personally would have thought it would be a relative path (and also can't really think of why anyone would want an absolute path), it would have allowed portability, or at least minimal configuration changes to simply make a copy of the site in a subdir. For that reason I almost never use absolute paths unless explicitly necessary (such as referencing assets that don't need to be duplicated.) It also breaks Crowdin, which is rather important.

Would have thought such a breaking change would appear in the changelog, but I guess my assumptions and the actual intent were different this whole time.

It would be nice if the paths specified in the locales config would make each locale its own base path, but I guess that belongs in a feature request.

Futher more, you can get relative path title, like what we are doing at PageNav (prev and next link)

Is there some reference that I can look at? I can't seem to find it in theme-default.

Mister-Hope commented 1 month ago

https://github.com/vuepress/ecosystem/blob/main/themes%2Ftheme-default%2Fsrc%2Fclient%2Fcomponents%2FPageNav.vue#L31-L40

lifehackerhansol commented 1 month ago

Issue NACKed.