@ice/route-manifest
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

@ice/route-manifest

Generate route manifest based on the src directory in the project for ice.js 3.

API

generateRouteManifest(rootDir: string)

  • rootDir: the project directory absolute path

Will scan the page files in the rootDir and generate the routeManifest. For example:

const routeManifest = generateRouteManifest(__dirname);
console.log(routeManifest);
/**
[
  layout: {
    path: "",
    id: "layout",
    componentName: "Layout",
    file: "layout.tsx",
  },
  "pages/About/index": {
    path: "/About",
    index: true,
    id: "pages/About/index",
    parentId: "layout",
    file: "pages/About/index.tsx",
    componentName: "PagesAboutIndex",
  },
}
*/

formatNestedRouteManifest(routeManifest: RouteManifest)

  • routeManifest: generated by the generateRouteManifest function

It will get the nested route by the routeManifest. For example:

routeManifest:

const routeManifest = [
  layout: {
    path: "",
    id: "layout",
    componentName: "Layout",
    file: "layout.tsx",
  },
  "pages/About/index": {
    path: "/About",
    index: true,
    id: "pages/About/index",
    parentId: "layout",
    file: "pages/About/index.tsx",
    componentName: "PagesAboutIndex",
  },
}

const nestedRouteManifest = formatNestedRouteManifest(routeManifest);

console.log(nestedRouteManifest);
/**
[
  {
    path: "",
    id: "layout",
    componentName: "Layout",
    file: "layout.tsx",
    children: [
      {
        path: "/About",
        index: true,
        id: "pages/About/index",
        parentId: "layout",
        file: "pages/About/index.tsx",
        componentName: "PagesAboutIndex",
      },
    ]
  }
]
*/

Readme

Keywords

none

Package Sidebar

Install

npm i @ice/route-manifest

Homepage

v3.ice.work

Weekly Downloads

130

Version

1.2.2

License

MIT

Unpacked Size

30.2 kB

Total Files

8

Last publish

Collaborators

  • linbudu
  • answershuto
  • chenjun1011
  • luhengchang228
  • sobear
  • clarkxia
  • rax-publisher