Generating correct links when the clean-urls plugin is used.
Let's assume the plugin is used with the options { normalSuffix: '/', indexSuffix: '/' } and a page guide.md.
The plugin modifies the path of the resulting page, so that it gets exported as guide/index.html instead of the standard guide.html.
This solves only one part of the problem though, as the links generated by Vuepress are still guide.html. As the warning in the plugin README mentions, this isn't a problem as long as JavaScript is used because the router handles both cases. But following those links without JavaScript or opening them in a separate window/tab leads to the 404 page, because there is no guide.html but guide/index.html. We noticed this when adding a broken link checker to our project.
As a solution to that, the proposed change gives the option to configure the links that get generated by Vuepress, so that users and plugins can hook into that. In parts, this request relates to #2420 and #2424.
Extending the markdown link plugin with an option for the suffix, which is currently hardcoded to be .html.
.htmltoRouterLink of the markdown link plugin to make use of the new option:- .replace(/\.md$/, '.html')
+ .replace(/\.md$/, suffix)
- .replace(/\.md(#.*)$/, '.html$1')
+ .replace(/\.md(#.*)$/, `${suffix}$1`)
Yes, if this is a wanted change I could take it on.
I verified that this works at least for the described case by monkey-patching the link.js file.
There might be edge cases involved though, but the cases described in #2420 and #2424 seem like other good real-world examples.
Inviting feedback from @bencodezen @billyyyyy3320 @kefranabg :)
I am keen to see a solution for this and @dennisreimann's suggestion seems simple and elegant, would this change be accepted if a PR is made?
I could provide a pull request 鈥撀燼nyone from core interested in this?
Inviting feedback from @bencodezen @billyyyyy3320 @kefranabg :)
@dennisreimann Sorry for the very late reply. It sounds great to me.
Also, IMO, the config should be a property of Markdown config.
cc @Shigma @meteorlxy (Plugin authors)
@billyyyyy3320 Thanks for the feedback, I provided the PR #2674.
Most helpful comment
@billyyyyy3320 Thanks for the feedback, I provided the PR #2674.