core
core copied to clipboard
feat: add route option (close #1505)
[!warning] This PR is now based on https://github.com/vuepress/core/pull/1562, so it's expected #1562 to be merged first.
[!tip] For a file like
/a/b.md, the full format is/a/b.htmland clean format is/a/b
Features
This pr adds route option for vuepress config file.
- New
route.cleanUrloption to support the "clean format" pagePatternsandpermalinkPattenis moved toroute.pagePatternsandroute.permalinkPatten
Bug Fixes
Previously, when use manually set a permalink or page path to a clean format like /a, they will always get 404 when trying to visit the page (in any link format). Now, this is correctly handled. Page path will be normalized to a "full" or "clean" version based on cleanUrl, no matter user use "clean", "full" format or mixing them.
Performance Improvements
Now, the key in routes is always the clean format, which avoid outputting uncessary .html suffix for most pages.
Potential Breaking Changes
- Now
inferRoutePathandnormalizeRoutePathreturn the "clean" format instead of "full" format.
Tweaks
Now a new field called routeKey is on the Page object.
Pull Request Test Coverage Report for Build 13690296414
Details
- 17 of 18 (94.44%) changed or added relevant lines in 8 files are covered.
- No unchanged relevant lines lost coverage.
- Overall coverage increased (+0.2%) to 71.873%
| Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
|---|---|---|---|
| packages/cli/src/commands/dev/watchPageFiles.ts | 0 | 1 | 0.0% |
| <!-- | Total: | 17 | 18 |
| Totals | |
|---|---|
| Change from base Build 13616164910: | 0.2% |
| Covered Lines: | 654 |
| Relevant Lines: | 912 |
💛 - Coveralls
now e2e test is added in this PR
A little weird to me, I can not reproduce the CI result locally
@Mister-Hope
In the e2e/docs/components/route-link.md file, the title is Query and hash, but in the e2e/tests/components/route-link.spec.ts file, the locator is:
- .e2e-theme-content #hash-and-query + ul > li a
^^^^^^^^^^^^^^
+ .e2e-theme-content #query-and-hash + ul > li a
which causes the e2e test to fail due to the inability to find the element.
I would really love to see this in VuePress, this is the one thing preventing me from using it.
If @meteorlxy is happy to review it, then I am totally fine to refine this asap.