Skip to content

Ability to prevents page generation in generate:page #7440

@farnabaz

Description

@farnabaz

What problem does this feature solve?

What if we can add a single boolean to the page variable to conditionally control page generation?

https://github.com/nuxt/nuxt.js/blob/c14471681c7134a6a08a69f9eabdb7d213feb2f0/packages/generator/src/generator.js#L361-L373

What does the proposed changes look like?

// Call hook to let user update the path & html
    const page = { route, path: fileName, html, generate: true }
    await this.nuxt.callHook('generate:page', { page, errors: pageErrors })
    await this.nuxt.callHook('export:page', { page })
  
    if (page.generate) {
        page.path = path.join(this.distPath, page.path)
        ...
    }

    return page.generate

Or for being fully backward compatible we could use export:page hook:

    const page = { route, path: fileName, html, generate: true }
...
    await this.nuxt.callHook('export:page', { page, errors: pageErrors })
  
    if (page.generate) {
...
This feature request is available on Nuxt community (#c10713)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions