vite-plugin-pages icon indicating copy to clipboard operation
vite-plugin-pages copied to clipboard

Unified custom route data

Open cubxx opened this issue 5 months ago • 0 comments

Description

SFC custom block and JSX/TSX YAML format comments are not perfect method to custom route data, especially when I want to use imported data in route data:

import { mdiHomeOutline } from '@mdi/js';
const route = {
  meta: {
    btnProps: {
      tip: 'home',
      icon: mdiHomeOutline,
      order: 2,
      hideOn: 'mobile',
    },
  },
}

Suggested solution

custom route data in runtime code is maybe better method, it has natural framework-independence advantage, and support type check:

// src/pages/index.tsx
import type { RouteMeta } from 'vue-router';
import { mdiHomeOutline } from '@mdi/js';
export const route = {
  meta: {
    btnProps: {
      tip: 'home',
      icon: mdiHomeOutline,
      order: 2,
      hideOn: 'mobile',
    } satisfies RouteMeta,
  },
}
export default ...

Alternative

No response

Additional context

No response

Validations

  • [X] Follow the Code of Conduct
  • [X] Read the docs.
  • [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

cubxx avatar Sep 17 '24 10:09 cubxx