Skip to content

fix(core): page creation should respect page options#1673

Open
Mister-Hope wants to merge 3 commits intomainfrom
path-fix
Open

fix(core): page creation should respect page options#1673
Mister-Hope wants to merge 3 commits intomainfrom
path-fix

Conversation

@Mister-Hope
Copy link
Member

See vuepress-theme-hope/vuepress-theme-hope#5193
vuepress-theme-hope/vuepress-theme-hope#5188

Basically, createPage shall respect path in pageOptions, giving correct pageLocale and lang

@coveralls
Copy link

coveralls commented Feb 1, 2026

Pull Request Test Coverage Report for Build 21566506449

Details

  • 4 of 4 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 73.534%

Totals Coverage Status
Change from base Build 19128283464: 0.1%
Covered Lines: 683
Relevant Lines: 931

💛 - Coveralls

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes page creation to properly respect the path option in pageOptions, ensuring correct locale and language resolution. Previously, when an explicit path was provided via options.path, the inferPagePath function would ignore it and only use the file path, leading to incorrect locale inference.

Changes:

  • Modified inferPagePath to check and use options.path first before falling back to file-based inference
  • Updated createPage to pass the options parameter to inferPagePath
  • Updated all test calls to inferPagePath to include the new required options parameter

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/core/src/page/inferPagePath.ts Added logic to check options.path first and resolve locale from it before falling back to file-based path inference
packages/core/src/page/createPage.ts Updated call to inferPagePath to pass the options parameter
packages/core/tests/page/inferPagePath.spec.ts Added empty options: {} parameter to all test calls for inferPagePath
packages/core/tests/page/createPage.spec.ts Updated expectation for pathInferred from null to '/' for pages created with explicit path
Comments suppressed due to low confidence (1)

packages/core/src/page/inferPagePath.ts:11

  • The function documentation should be updated to reflect the new behavior. The comment currently states "Infer page path according to file path" but the function now also handles explicit paths from options.path. Consider updating the documentation to something like "Infer or resolve page path from options or file path" to accurately reflect that it can return an explicitly provided path rather than just inferring from the file path.
/**
 * Infer page path according to file path
 *
 * @internal

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// infer page path according to file path
const { pathInferred, pathLocale } = inferPagePath({ app, filePathRelative })
const { pathInferred, pathLocale } = inferPagePath({
Copy link
Member

Choose a reason for hiding this comment

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

As inferPagePath is to infer page path and locale, maybe we could update to something like that:

const { pathInferred, pathInferredLocale }  = inferPagePath({ app, filePathRelative });
const pathLocale = resolvePagePathLocale({ pathInferredLocale, options });

Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments