Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.6.6 版本更新后,将路由更改为中文,点击文章链接无效,无法跳转详情页 #346

Closed
steel-li opened this issue Apr 12, 2021 · 13 comments

Comments

@steel-li
Copy link

  • Your OS: 谷歌:89.0.4389.90,Edge:89.0.774.75
  • Node.js version: v14.16.0
  • VuePress version: v1.8.2
  • VuePress-theme-reco version: 1.6.6
  • Which package manager did you use for the install(npm/cnpm/yarn)?npm/yarn都选了
@scrushy
Copy link

scrushy commented Apr 17, 2021

我也遇到一样的问题

@wencwcoder
Copy link

@scrushy @ligang1628 最好还是使用英文命名吧,因为 vuepress 的路由跳转是基于 vue-router 的,可能是与其有关,建议还是英文命名,减少不必要的麻烦。

@brokyz
Copy link

brokyz commented May 14, 2021

同样,文章采用中文命名后无法解析为静态地址。改为英文命名后就没有这个问题。

@shirayner
Copy link

shirayner commented Jun 11, 2021

使用插件 vuepress-plugin-permalink-pinyin 可解决此问题,具体请参考 基于VuePress和GitHub搭建个人博客站点

当文件名含有中文时,对应页面无法跳转,可通过如下插件解决这个问题,这个插件会将中文路径转换为拼音路径

本地安装:

npm install -D  vuepress-plugin-permalink-pinyin

然后配置插件:

module.exports = {
  plugins: [
      // 支持中文文件名
      [
        "permalink-pinyin",
        {
          lowercase: true, // Converted into lowercase, default: true
          separator: "-", // Separator of the slug, default: '-'
        },
      ],
  ]
}

效果:
有如下中文文件

image

会被插件转成拼音路径,访问如下地址

https://shirayner.github.io/snote/cs/backend/java/jvm/01_jvmhe-xin-zhi-shi-dian-tu-jie.html

会发现中文路径已经被转成拼音了

image

@wencwcoder
Copy link

使用插件 vuepress-plugin-permalink-pinyin 可解决此问题,具体请参考 基于VuePress和GitHub搭建个人博客站点

当文件名含有中文时,对应页面无法跳转,可通过如下插件解决这个问题,这个插件会将中文路径转换为拼音路径

本地安装:

npm install -D  vuepress-plugin-permalink-pinyin

然后配置插件:

module.exports = {
  plugins: [
      // 支持中文文件名
      [
        "permalink-pinyin",
        {
          lowercase: true, // Converted into lowercase, default: true
          separator: "-", // Separator of the slug, default: '-'
        },
      ],
  ]
}

效果:
有如下中文文件

image

会被插件转成拼音路径,访问如下地址

https://shirayner.github.io/snote/cs/backend/java/jvm/01_jvmhe-xin-zhi-shi-dian-tu-jie.html

会发现中文路径已经被转成拼音了

image

👍

@sd445419855
Copy link

我也一样,文章或目录采用中文命名的就无法打开,在routes里看解析所有静态路由地址,发现文章或目录带中文路由信息里,有path 但没有对应的 components,而且还被redirect到一个中文被 encode 后的地址上。如果版本是 vuepress 1.2.0、@vuepress/core 1.3.1、vuepress-theme-reco 1.2.2 就啥问题都没有。

@sd445419855
Copy link

@wencwcoder 虽然 vuepress 的路由跳转是基于 vue-router 的,但这并不影响使用中文路径跳转,因为如果使用 vuepress 默认主题,就可以正常打开路径中带有中文的 md 文件了。

@wencwcoder
Copy link

@wencwcoder 虽然 vuepress 的路由跳转是基于 vue-router 的,但这并不影响使用中文路径跳转,因为如果使用 vuepress 默认主题,就可以正常打开路径中带有中文的 md 文件了。

上面的转换插件可以一试

@sd445419855
Copy link

sd445419855 commented Aug 20, 2021 via email

@ATQQ
Copy link
Contributor

ATQQ commented Jan 22, 2022

可以参考这个issue下的解决方案,添加一个router的钩子

https://github.com/vuepress-reco/vuepress-theme-reco/issues/395#issuecomment-1019087787

@duktig666
Copy link

使用插件 vuepress-plugin-permalink-pinyin 可解决此问题,具体请参考 基于VuePress和GitHub搭建个人博客站点
当文件名含有中文时,对应页面无法跳转,可通过如下插件解决这个问题,这个插件会将中文路径转换为拼音路径
本地安装:

npm install -D  vuepress-plugin-permalink-pinyin

然后配置插件:

module.exports = {
  plugins: [
      // 支持中文文件名
      [
        "permalink-pinyin",
        {
          lowercase: true, // Converted into lowercase, default: true
          separator: "-", // Separator of the slug, default: '-'
        },
      ],
  ]
}

效果:
有如下中文文件
image
会被插件转成拼音路径,访问如下地址

https://shirayner.github.io/snote/cs/backend/java/jvm/01_jvmhe-xin-zhi-shi-dian-tu-jie.html

会发现中文路径已经被转成拼音了
image

👍

vuepress-plugin-permalink-pinyin 这个插件使用默认的永久链接模式可以,但是如果修改永久链接模式为如下时会失效:

// 永久链接格式
permalink: "/:year/:month/:day/:slug",

@recoluan
Copy link
Member

主题2.0已经完美解决这个问题,咱们可以关注一下主题 2.0,后期 1.0 将不再维护了。

http://v2.vuepress-reco.recoluan.com/

@duktig666
Copy link

主题2.0已经完美解决这个问题,咱们可以关注一下主题 2.0,后期 1.0 将不再维护了。

http://v2.vuepress-reco.recoluan.com/

主题2.0计划什么时候发稳定版呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants