@soartec-lab/plop-create-remix-route
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

plop-create-remix-route

A plop generator for routes of Remix. The package was developed to simplify the generation of the route component of the Folders for Organization configuration in Remix

Installation

This package is hosted on npm.

npm install --save-dev @soartec-lab/plop-create-remix-route

If you haven't installed plop yet, please install it together.

npm install --save-dev plop

Usage

First, load it in the plop file. Update plopfile.js as follows:

export default async function (plop) {
+	await plop.load("@soartec-lab/plop-create-remix-route");
}

Now you are ready. Let's start the command.

$ npx plop create-remix-route-component

? Which type of component do you want to create? route from URL path
? What is the URL path?

  ex)

  | URL you need to input | route file path    | create component name |
  |-----------------------|--------------------|-----------------------|
  | /users                | users._index       | UsersRoute            |
  | /users/posts          | users.posts._index | UsersPostsRoute       |
  | users/:id             | users.$id          | UserRoute             |

  ? users/:id/posts/:id
✔  ++ /app/routes/users.$id.posts.$id/route.tsx
✔  ++ /app/routes/users.$id.posts.$id/route.test.tsx

Here, by selecting route from URL path as the component type to create and entering users/:id/posts/:id, we generate a route component that matches the URL.

Types of Components that Can Be Created

The component type that can be individually created are as follows:

route from URL path

If you want to create a route component from a URL path, select this type. For example, if you enter users/:id/posts/:id, the following files will be created:

  • app/routes/users.$id.posts.$id/route.tsx
  • app/routes/users.$id.posts.$id/route.test.tsx

route from file path

If you want to create a route component by specifying a file path, select this type. For example, if you enter users._index, the following files will be created:

  • app/routes/users._index/route.tsx
  • app/routes/users._index/route.test.tsx

feature

If you want to create a feature component instead of a route component, select this type. For example, if you choose users._index/user-list, the following files will be created:

  • app/routes/users._index/user-list.tsx
  • app/routes/users._index/user-list.test.tsx

Motivation

While routes of Remix is flexible and consistent, I find the catch-up cost high. Folders for Organization is one of the aspects. By using this library, you can create components more intuitively.

Questions

If you have any issues or ideas for feature additions, please create an issue or mention me on X. Feedback is welcome.

Readme

Keywords

Package Sidebar

Install

npm i @soartec-lab/plop-create-remix-route

Weekly Downloads

12

Version

1.0.0

License

MIT

Unpacked Size

14.4 kB

Total Files

18

Last publish

Collaborators

  • soartec-lab