Skip to content

Commit 0b3a99f

Browse files
committed
current status
0 parents  commit 0b3a99f

11 files changed

+762
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+
node_modules

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# @idrinth/react-file-based-routing
2+
3+
This is a small library used to teach the default react routers file based routing and optimise the output as far as that is possible without server side rendering. It is meant for mostly static pages, where the overhead of nextjs of vike is not required.
4+
5+
## Defining a page
6+
7+
A page is currently any ìndex.tsx within the src/pages folder. index.tsx in the root folder will not be processed correctly. The folder name will be taken as the page url, with two exceptions:
8+
9+
- home will be the root
10+
- not-found will be the 404 page
11+
12+
This is not yet configurable, but will be soon.
13+
14+
# Setup
15+
16+
You will need to do three things for the complete package:
17+
18+
- Define a call to generate-routes in you package.json as afterInstall and early in your build process to generate the routes.tsx and the sitemap
19+
- Define a call to generate-folders in your package.json as a late build step to optimise the index.html files
20+
- Import the generated src/routes.tsx, so that you can use createBrowserRouter or similar functions to create your router

bin/generate-folders.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env node
2+
import generate from '../src/generate-folders.js';
3+
4+
generate(process.cwd());

bin/generate-routes.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env node
2+
import generate from '../src/generate-routes.js';
3+
4+
generate(process.cwd(), process.argv[2]);

0 commit comments

Comments
 (0)