From 03f1574375321848d78c19b65d08d3191b834fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Xalambr=C3=AD?= Date: Mon, 13 May 2024 15:45:15 -0500 Subject: [PATCH] Update docs --- README.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- package.json | 4 ++-- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index efd9d09..b702646 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,51 @@ -# package +# remix-define-routes -A template to create new packages. +A DSL to define Remix routes with code. + +## Setup + +```bash +npm add remix-define-routes +``` + +Create a file called `routes.ts` in your Remix project. + +```ts +import { defineRoutes } from "remix-define-routes"; + +let authRoutes = defineRoutes(({ layout }) => { + layout("auth", { base: "routes/auth" }, ({ route }) => { + route("index", "routes/auth._index"); + route("register"); + route("login"); + }); +}); + +export default defineRoutes(({ route, extend }) => { + extend(authRoutes); + + route("api/healthcheck"); + route("index", "routes/_index"); + route("admin/:resource"); +}); +``` + +Then in your `vite.config.ts` import and use it to configure your Remix plugin. + +```ts +import { vitePlugin as remix } from "@remix-run/dev"; +import { defineConfig } from "vite"; + +import routes from "./config/routes"; + +export default defineConfig({ + plugins: [ + remix({ + ignoredRouteFiles: ["**/*"], + routes: () => routes, + }), + ], +}); +``` + +And now you can use route routes file to define your application routes. diff --git a/package.json b/package.json index 0e16dd4..a7fd901 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "package-name", + "name": "remix-define-routes", "version": "0.0.0", - "description": "A description of the package", + "description": "A DSL to define Remix routes with code", "license": "MIT", "funding": ["https://github.com/sponsors/sergiodxa"], "author": {