vuepress / core

Vue-Powered Static Site Generator
https://vuepress.vuejs.org
MIT License
2.16k stars 922 forks source link

feat: add route option (close #1505) #1538

Open Mister-Hope opened 2 months ago

Mister-Hope commented 2 months ago

[!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.html and clean format is /a/b

Features

This pr adds route option for vuepress config file.

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

Tweaks

Now a new field called routeKey is on the Page object.

coveralls commented 1 month ago

Pull Request Test Coverage Report for Build 9219541970

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/cli/src/commands/dev/watchPageFiles.ts 0 1 0.0%
packages/client/src/router/resolveRoutePath.ts 0 2 0.0%
packages/core/src/app/prepare/prepareRoutes.ts 0 2 0.0%
packages/client/src/router/resolveRouteFullPath.ts 0 3 0.0%
packages/client/src/setupGlobalComputed.ts 0 3 0.0%
packages/client/src/router/resolveRoute.ts 0 5 0.0%
packages/client/src/router/resolveRouteKey.ts 0 10 0.0%
<!-- Total: 23 49 46.94% -->
Totals Coverage Status
Change from base Build 9211217292: -0.04%
Covered Lines: 695
Relevant Lines: 1729

💛 - Coveralls
Mister-Hope commented 1 month ago

now e2e test is added in this PR

Mister-Hope commented 1 month ago

image

A little weird to me, I can not reproduce the CI result locally