core icon indicating copy to clipboard operation
core copied to clipboard

feat: add route option (close #1505)

Open Mister-Hope opened this issue 1 year ago • 6 comments

[!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.

  • New route.cleanUrl option to support the "clean format"
  • pagePatterns and permalinkPatten is moved to route.pagePatterns and route.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 inferRoutePath and normalizeRoutePath return the "clean" format instead of "full" format.

Tweaks

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

Mister-Hope avatar Apr 11 '24 16:04 Mister-Hope