feat($core): redirects for clean urls #1269
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
In VuePress, we have following convention about routing:
/foo/
means source file is/foo/{README|index}.md
/foo.html
means your source file is/foo.md
The original design of VuePress relied on above two styles
of routing, especially the calculation involved of routes at
// default theme. so we can't easily modify
/foo.html
directlyto
/foo
(i.e. remove html suffix)This utility handles redirect of clean urls, with this utility, you'll
get:
For unknown request
/foo
/foo.html
if it exists/foo/
if it existsFor unknown request
/foo/
/foo.html
if it existsIf all the above redirect rules don't exist, you'll get a 404
Note that this PR doesn't provide you the ability to remove the
html suffix at the route level, it just allows you to use clean urls.
cc @octref
Related: #603
Related: #608
Related: #1060
Close: #720
Close: #931