Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Dynamic Routes]: Add transformPageData configure #2637

Open
4 tasks done
Zhengqbbb opened this issue Jul 17, 2023 · 1 comment
Open
4 tasks done

[Dynamic Routes]: Add transformPageData configure #2637

Zhengqbbb opened this issue Jul 17, 2023 · 1 comment
Labels
build Related to the build system enhancement New feature or request stale

Comments

@Zhengqbbb
Copy link
Contributor

Zhengqbbb commented Jul 17, 2023

Is your feature request related to a problem? Please describe.

ref: #883 (comment) #2516

When I using Dynamic Routes. To uniformly manage and generate pages with a consistent structure, which involves changing the header title #2516, the suggestion is also to use .vitepress/config.js to use transformPageData

// .vitepress/config.js
{
  // ...
  transformPageData: (pageData, { siteConfig }) => {
    if (page-foo) {
       // change header, title and resolve page data
    } else if (page-bar) {
       // ...
    }
}

Describe the solution you'd like

I think if transformPageData would be in Dynamic Routes configure [pkg].paths.js. Avoid me adding too many logic in .vitepress/config.js, and just managing it in only one place. clear and good management

.
└─ packages
   ├─ [pkg].md         # route template
   └─ [pkg].paths.js   # route paths loader
// packages/[pkg].paths.js
export default {
  paths() {
    return [
      { params: { pkg: 'foo' }},
      { params: { pkg: 'bar' }}
    ]
  },
  transformPageData(pageData) {
    // ...
  }
}

Describe alternatives you've considered

No response

Additional context

No response

Validations

@brc-dd brc-dd added enhancement New feature or request build Related to the build system labels Aug 3, 2023
@davay42
Copy link

davay42 commented Aug 19, 2023

Very needed feature. I couldn't figure out how to populate just the 'title:' frontmatter for these dynamic pages without this option. @Zhengqbbb thanks for the tip with use of the transformPageData!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Related to the build system enhancement New feature or request stale
Projects
None yet
Development

No branches or pull requests

3 participants