hannoeru / vite-plugin-pages

File system based route generator for ⚡️Vite
MIT License
1.84k stars 127 forks source link

TSX/JSX consider support to define meta by jsdoc with import types #394

Closed morlay closed 10 months ago

morlay commented 1 year ago

Description

We could extract meta from Typescript jsdoc

https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#import-types

Not like yaml, with Typescript jsdoc, we could got strongly type for route meta.

Suggested solution

/**
 * @property {"account"} meta.name
 * @property {typeof import("@mdi/js").mdiPlus} meta.icon
 */
export default defineComponent({})  

Then we could pick the info from jsdoc.

To generate route with picked meta.

import { mdiPlus } from  "@mdi/js"

const component = {
  meta:  {
    name: "account", 
    icon: mdiPlus
  }
}

const routes = [{ component, ... }]

For import type, we could generate routes with required module imports.

Alternative

No response

Additional context

No response

Validations