Skip to content

definePageMeta({path: '...'}) doesn't works in static rendering #2855

Open
@jeannen

Description

@jeannen

Environment



Reproduction

  1. Create a page (example: /pages/demo.vue)

  2. Add page meta different from the name of the file

Inside /pages/demo.vue:

<script setup>
    definePageMeta({
        path: '/foo',
    });
</script>
  1. Use npm run generate
Errors prerendering:
  ├─ /api/_content/query/2kJ8ihpm0Q.1700289623443.json (107ms)                                                                                                                                 nitro 2:40:37 PM
  │ ├── Error: [404] Document not found!
  │ └── Linked from /demo

Describe the bug

When a page with definePageMeta()'s path that does not match the file name is specified, it prevents the static site from being generated.

It works fine when using npm run dev

It would be nice to have this working to organize the /pages folder a bit more and put pages inside folders

(My original use case was to create a page with a path note/:id instead of making a folder with only one catch-all page inside)

Additional context

No response

Logs

Errors prerendering:
  ├─ /api/_content/query/76BoSDA4U0.1700289877623.json (130ms)                                                                                                                                 nitro 2:44:52 PM
  │ ├── Error: [404] Document not found!
  │ └── Linked from /demo
                                                                                                                                                                                               nitro 2:44:52 PM

 ERROR  Exiting due to prerender errors.                                                                                                                                                             2:44:52 PM

  at prerender (node_modules/nitropack/dist/shared/nitro.3d0a4b01.mjs:214:11)
  at async node_modules/nuxt/dist/index.mjs:2986:7
  at async build (node_modules/nuxt/dist/index.mjs:4375:5)
  at async Object.run (node_modules/nuxi/dist/chunks/build.mjs:92:5)
  at async Object.run (node_modules/nuxi/dist/chunks/generate.mjs:61:5)
  at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.c6444792.mjs:1647:7)
  at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.c6444792.mjs:1638:11)
  at async runMain$1 (node_modules/nuxi/dist/shared/nuxi.c6444792.mjs:1770:7) 



 ERROR  Exiting due to prerender errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    StalebugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions