Skip to content

✨ Remove '.html' extension from URLs #1060

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
node_modules
*.log
.temp
.vscode
TODOs.md
vuepress
6 changes: 3 additions & 3 deletions packages/@vuepress/shared-utils/lib/fileToPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ module.exports = function fileToPath (file) {
// foo/README.md -> /foo/
return file.replace(indexRE, '/$1')
} else {
// foo.md -> /foo.html
// foo/bar.md -> /foo/bar.html
return `/${file.replace(extRE, '').replace(/\\/g, '/')}.html`
// foo.md -> /foo/
// foo/bar.md -> /foo/bar/
return `/${file.replace(extRE, '').replace(/\\/g, '/')}/`
}
}
3 changes: 2 additions & 1 deletion packages/@vuepress/theme-default/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export function normalize (path) {
return decodeURI(path)
.replace(hashRE, '')
.replace(extRE, '')
.replace(endingSlashRE, '')
}

export function getHash (path) {
Expand Down Expand Up @@ -39,7 +40,7 @@ export function ensureExt (path) {
if (endingSlashRE.test(normalized)) {
return path
}
return normalized + '.html' + hash
return normalized + '/' + hash
}

export function isActive (route, path) {
Expand Down