Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

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

wants to merge 6 commits into from

Conversation

Mister-Hope
Copy link
Member

@Mister-Hope Mister-Hope commented Apr 11, 2024

Warning

This PR is now based on #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 Mister-Hope linked an issue Apr 11, 2024 that may be closed by this pull request
@meteorlxy meteorlxy changed the title feat: add route option feat: add route option (close #1505) May 14, 2024
@coveralls
Copy link

coveralls commented May 16, 2024

Pull Request Test Coverage Report for Build 13475324265

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%
Totals Coverage Status
Change from base Build 13450802257: 0.2%
Covered Lines: 654
Relevant Lines: 912

💛 - Coveralls

@Mister-Hope
Copy link
Member Author

now e2e test is added in this PR

@Mister-Hope
Copy link
Member Author

image

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

@pengzhanbo
Copy link
Member

@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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#L94-L100

image

The regular expression here does not satisfy path matching after enabling cleanUrl. For strings in the format of /xxx, it always returns false, and the value of href in linksPlugin is skipped during parsing, resulting in /xxx instead of /xxx.html.

The regular expression requires that the path part must end with /, .html, or .md, and it is clear that /xxx does not meet this requirement.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is excepted, even with cleanUrl, users are required to add .md extension .

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug report] add extra pages seems to have no effect [Feature request] CleanUrl
3 participants