-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Support filename that contains non-ASCII and unicode chars #473
Conversation
@@ -320,7 +322,7 @@ async function genRoutesFile ({ siteData: { pages }, sourceDir, pageFiles }) { | |||
component: ThemeLayout, | |||
beforeEnter: (to, from, next) => { | |||
import(${JSON.stringify(filePath)}).then(comp => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果 filepath 包含 !
号,如:/docs/hello!.md
,因为使用了 Webpack,!
前面的内容会被认为是 loader 的配置,见:https://webpack.js.org/concepts/loaders/#inline。在我的 PR 中,我使用了 webpack-virtual-modules 解决了这个问题。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since webpack does not support the path containing !
and even throw error for that: webpack/webpack#6754 .
So we don't need to introduce webpack-virtual-modules
to support !
which should be handled by webpack instead of VuePress.
We don't need to introduce a huge hack to cater to it for an illegal use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
哈哈,补充下我的思路。
文件:/docs/hello!.md
我们可以在 VuePress 里读取 hello!.md
的内容,并用它生成一个与 hello!.md
同级的 virtual module,比如:docs/page-1.md
,然后 import('docs/page-1.md')
,如此即可避免 !
的问题,同时因为是同级目录,原文件里的路径都不用改变。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我用中文重申一下:我们没有必要为了一个并不合法的极少数用例来引入庞大的代码hack。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好吧,我想 !
仅仅是对于 Webpack
不合法。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
既然 VuePress 基于 Webpack,本着职责清晰的原则,我们不应该在 VuePress 中来解决 Webpack 的问题,万一哪天 Webpack 有自己的解决方案呢?此外,你这种解决方案太复杂了。
如果你需要这个 feature,请给 Webpack 提 Issue 或者 PR,谢谢。
dbcea25
to
9e7a3dc
Compare
Background
There is a previous issue of Vue-Router: vuejs/vue-router#838, when using non-ASCII chars as filename, e.g.
尤.md
, there will be some issues:Fixed
page-尤.md
:This PR leverage the random hash string prefixed with
v-
to generate the page component name.P.S: Testing markdown change will be removed before merged.
Test Coverage
To be fixed
Updated: This following issue has been fixed at 9e7a3dc, so you can ignore it.
This PR isn't perfect, which still has an issue, setup to repro:
尤
at content to go to: https://deploy-preview-473--vuepress.netlify.com/尤.htmlOr:
I took much time to try to fix it, but still cannot fixed it perfectly.
@yyx990803 Would you please help to review this PR? thanks a lot.