reroute-js 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/_/basic/package.json +4 -4
- package/_/basic/src/client/index.html +1 -1
- package/_/basic/src/index.ts +1 -3
- package/_/blog/package.json +4 -4
- package/_/blog/src/client/App.tsx +1 -0
- package/_/blog/src/client/index.html +1 -1
- package/_/blog/src/client/routes/blog/content/1-hello-world.tsx +1 -1
- package/_/blog/src/client/routes/blog/content/3-markdown-with-syntax-highlighting.mdx +213 -0
- package/_/blog/src/client/routes/blog/content/4-content-in-markdown.md +143 -0
- package/_/blog/src/client/routes/blog/content/5-mdx-with-components.mdx +267 -0
- package/_/blog/src/client/routes/blog/index.tsx +59 -0
- package/_/blog/src/client/routes/client.tsx +564 -0
- package/_/blog/src/client/routes/docs.tsx +670 -0
- package/_/blog/src/client/routes/index.tsx +37 -0
- package/_/blog/src/client/routes/markdown-demo.md +169 -0
- package/_/blog/src/client/routes/markdown.tsx +160 -0
- package/_/blog/src/index.ts +5 -2
- package/_/store/package.json +4 -4
- package/_/store/src/client/index.html +1 -1
- package/_/store/src/index.ts +1 -1
- package/cli/bin.d.ts +1 -1
- package/cli/bin.js +806 -14
- package/cli/bin.js.map +11 -7
- package/cli/index.d.ts +1 -1
- package/cli/index.js +52 -3
- package/cli/index.js.map +4 -3
- package/cli/src/cli.d.ts +1 -1
- package/cli/src/commands/boot.d.ts +1 -1
- package/cli/src/commands/build.d.ts +19 -0
- package/cli/src/commands/build.d.ts.map +1 -0
- package/cli/src/commands/dev.d.ts +18 -0
- package/cli/src/commands/dev.d.ts.map +1 -0
- package/cli/src/commands/gen.d.ts +1 -1
- package/cli/src/commands/init.d.ts +1 -1
- package/cli/src/commands/start.d.ts +19 -0
- package/cli/src/commands/start.d.ts.map +1 -0
- package/cli/src/libs/index.d.ts +2 -1
- package/cli/src/libs/index.d.ts.map +1 -1
- package/cli/src/libs/log.d.ts +46 -0
- package/cli/src/libs/log.d.ts.map +1 -0
- package/cli/src/libs/markdown-processor.d.ts +1 -1
- package/cli/src/libs/markdown.d.ts +1 -1
- package/cli/src/libs/tailwind.d.ts +1 -1
- package/cli/src/libs/version.d.ts +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js +5 -5
- package/core/index.js.map +3 -3
- package/core/src/bundler/hash.d.ts +1 -1
- package/core/src/bundler/index.d.ts +1 -1
- package/core/src/bundler/transpile.d.ts +1 -1
- package/core/src/content/discovery.d.ts +1 -1
- package/core/src/content/index.d.ts +1 -1
- package/core/src/content/metadata.d.ts +1 -1
- package/core/src/content/registry.d.ts +1 -1
- package/core/src/index.d.ts +1 -1
- package/core/src/ssr/data.d.ts +1 -1
- package/core/src/ssr/index.d.ts +1 -1
- package/core/src/ssr/modules.d.ts +1 -1
- package/core/src/ssr/render.d.ts +1 -1
- package/core/src/ssr/seed.d.ts +1 -1
- package/core/src/template/html.d.ts +1 -1
- package/core/src/template/index.d.ts +1 -1
- package/core/src/types.d.ts +1 -1
- package/core/src/utils/cache.d.ts +1 -1
- package/core/src/utils/compression.d.ts +1 -1
- package/core/src/utils/index.d.ts +1 -1
- package/core/src/utils/mime.d.ts +1 -1
- package/core/src/utils/path.d.ts +1 -1
- package/elysia/index.d.ts +1 -1
- package/elysia/index.js +5 -5
- package/elysia/index.js.map +3 -3
- package/elysia/src/index.d.ts +1 -1
- package/elysia/src/libs/http.d.ts +1 -1
- package/elysia/src/libs/image.d.ts +1 -1
- package/elysia/src/plugin.d.ts +1 -1
- package/elysia/src/routes/artifacts.d.ts +1 -1
- package/elysia/src/routes/content.d.ts +1 -1
- package/elysia/src/routes/dev.d.ts +1 -1
- package/elysia/src/routes/image.d.ts +1 -1
- package/elysia/src/routes/ssr.d.ts +1 -1
- package/elysia/src/routes/static.d.ts +1 -1
- package/elysia/src/types.d.ts +1 -1
- package/package.json +6 -1
- package/react/index.d.ts +1 -1
- package/react/index.js +50 -24
- package/react/index.js.map +3 -3
- package/react/src/components/ClientOnly.d.ts +1 -1
- package/react/src/components/ContentRoute.d.ts +1 -1
- package/react/src/components/Image.d.ts +1 -1
- package/react/src/components/Link.d.ts +1 -1
- package/react/src/components/Markdown.d.ts +1 -1
- package/react/src/components/Outlet.d.ts +1 -1
- package/react/src/components/index.d.ts +1 -1
- package/react/src/hooks/index.d.ts +1 -1
- package/react/src/hooks/useContent.d.ts +1 -1
- package/react/src/hooks/useData.d.ts +1 -1
- package/react/src/hooks/useNavigate.d.ts +1 -1
- package/react/src/hooks/useParams.d.ts +1 -1
- package/react/src/hooks/useRouter.d.ts +1 -1
- package/react/src/hooks/useSearchParams.d.ts +1 -1
- package/react/src/index.d.ts +1 -1
- package/react/src/providers/ContentProvider.d.ts +1 -1
- package/react/src/providers/RerouteProvider.d.ts +1 -1
- package/react/src/providers/RouterProvider.d.ts +1 -1
- package/react/src/providers/RouterProvider.d.ts.map +1 -1
- package/react/src/providers/index.d.ts +1 -1
- package/react/src/types/any.d.ts +1 -1
- package/react/src/types/index.d.ts +1 -1
- package/react/src/types/router.d.ts +1 -1
- package/react/src/utils/content.d.ts +1 -1
- package/react/src/utils/head.d.ts +1 -1
- package/react/src/utils/index.d.ts +1 -1
- package/_/blog/src/client/components/Counter.tsx +0 -14
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Markdown Routes Demo
|
|
3
|
+
description: This page is rendered directly from a markdown file in the routes directory
|
|
4
|
+
date: 2025-01-15
|
|
5
|
+
slug: markdown-demo
|
|
6
|
+
excerpt: Learn how Reroute natively supports markdown files as routes with frontmatter
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Native Markdown Routes
|
|
10
|
+
|
|
11
|
+
Welcome to a page that's **entirely written in markdown**! This file lives in `src/client/routes/markdown-demo.md` and is automatically converted to a route by Reroute.
|
|
12
|
+
|
|
13
|
+
## How It Works
|
|
14
|
+
|
|
15
|
+
1. Drop a `.md` or `.mdx` file in your routes directory
|
|
16
|
+
2. Add frontmatter at the top for metadata
|
|
17
|
+
3. Reroute automatically converts it to a React component
|
|
18
|
+
4. The route is available at the filename path
|
|
19
|
+
|
|
20
|
+
## Frontmatter Support
|
|
21
|
+
|
|
22
|
+
The metadata at the top of this file (between `---` delimiters) becomes the page's meta tags:
|
|
23
|
+
|
|
24
|
+
```yaml
|
|
25
|
+
---
|
|
26
|
+
title: Markdown Routes Demo
|
|
27
|
+
description: This page is rendered directly from a markdown file
|
|
28
|
+
date: 2025-01-15
|
|
29
|
+
slug: markdown-demo
|
|
30
|
+
---
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
This data is used for:
|
|
34
|
+
- `<title>` tags
|
|
35
|
+
- `<meta name="description">` tags
|
|
36
|
+
- Open Graph and Twitter cards
|
|
37
|
+
- Content collections
|
|
38
|
+
|
|
39
|
+
## Syntax Highlighting
|
|
40
|
+
|
|
41
|
+
Code blocks automatically get syntax highlighting with Shiki:
|
|
42
|
+
|
|
43
|
+
### TypeScript
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
interface BlogPost {
|
|
47
|
+
title: string;
|
|
48
|
+
slug: string;
|
|
49
|
+
date: string;
|
|
50
|
+
content: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function getPost(slug: string): Promise<BlogPost> {
|
|
54
|
+
const response = await fetch(`/api/posts/${slug}`);
|
|
55
|
+
return response.json();
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### JavaScript
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
const fibonacci = (n) => {
|
|
63
|
+
if (n <= 1) return n;
|
|
64
|
+
return fibonacci(n - 1) + fibonacci(n - 2);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
console.log(fibonacci(10));
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Bash
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Install Reroute
|
|
74
|
+
bunx reroute-js init my-blog --template blog
|
|
75
|
+
|
|
76
|
+
# Navigate and start
|
|
77
|
+
cd my-blog
|
|
78
|
+
bun dev
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Rich Formatting
|
|
82
|
+
|
|
83
|
+
You can use all standard markdown features:
|
|
84
|
+
|
|
85
|
+
### Lists
|
|
86
|
+
|
|
87
|
+
**Unordered:**
|
|
88
|
+
- First item
|
|
89
|
+
- Second item with **bold text**
|
|
90
|
+
- Third item with *italic text*
|
|
91
|
+
- Fourth item with `inline code`
|
|
92
|
+
|
|
93
|
+
**Ordered:**
|
|
94
|
+
1. Step one
|
|
95
|
+
2. Step two
|
|
96
|
+
3. Step three
|
|
97
|
+
|
|
98
|
+
### Task Lists
|
|
99
|
+
|
|
100
|
+
- [x] Create markdown processor
|
|
101
|
+
- [x] Add frontmatter support
|
|
102
|
+
- [x] Integrate with routing system
|
|
103
|
+
- [ ] Add more examples
|
|
104
|
+
|
|
105
|
+
### Blockquotes
|
|
106
|
+
|
|
107
|
+
> "The best way to predict the future is to invent it."
|
|
108
|
+
> — Alan Kay
|
|
109
|
+
|
|
110
|
+
### Tables
|
|
111
|
+
|
|
112
|
+
| Feature | Status | Package |
|
|
113
|
+
|---------|--------|---------|
|
|
114
|
+
| Markdown Routes | ✅ | Built-in |
|
|
115
|
+
| Frontmatter | ✅ | Built-in |
|
|
116
|
+
| Syntax Highlighting | ✅ | shiki |
|
|
117
|
+
| GFM Support | ✅ | remark-gfm |
|
|
118
|
+
|
|
119
|
+
### Text Styling
|
|
120
|
+
|
|
121
|
+
You can use **bold**, *italic*, ***bold and italic***, ~~strikethrough~~, and `inline code`.
|
|
122
|
+
|
|
123
|
+
### Links
|
|
124
|
+
|
|
125
|
+
Check out the [Reroute repository](https://github.com/stewones/reroute) on GitHub!
|
|
126
|
+
|
|
127
|
+
## Horizontal Rule
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Why Markdown Routes?
|
|
132
|
+
|
|
133
|
+
Markdown routes are perfect for:
|
|
134
|
+
|
|
135
|
+
- 📝 **Blog posts** - Write content without JSX boilerplate
|
|
136
|
+
- 📚 **Documentation** - Focus on content, not components
|
|
137
|
+
- 📄 **Static pages** - About, terms, privacy policy, etc.
|
|
138
|
+
- ⚡ **Fast authoring** - Use any markdown editor
|
|
139
|
+
|
|
140
|
+
## Under the Hood
|
|
141
|
+
|
|
142
|
+
When you run `reroute gen`:
|
|
143
|
+
|
|
144
|
+
1. The CLI scans for `.md` and `.mdx` files
|
|
145
|
+
2. Parses frontmatter using a built-in parser
|
|
146
|
+
3. Generates a React component wrapper
|
|
147
|
+
4. Saves it to `.reroute/markdown/`
|
|
148
|
+
5. Routes system imports it like any other route
|
|
149
|
+
|
|
150
|
+
The generated component uses the `<Markdown>` component with optional Shiki highlighting and GFM support!
|
|
151
|
+
|
|
152
|
+
## Next Steps
|
|
153
|
+
|
|
154
|
+
Try creating your own markdown routes:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
# Create a new markdown file
|
|
158
|
+
touch src/client/routes/my-page.md
|
|
159
|
+
|
|
160
|
+
# Add some frontmatter and content
|
|
161
|
+
# Run the generator
|
|
162
|
+
bun dev
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Your page will be available at `/my-page`!
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
*This entire page was written in plain markdown* ✨
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { Link, Markdown } from 'reroute-js/react';
|
|
2
|
+
|
|
3
|
+
export default function MarkdownDemo() {
|
|
4
|
+
const exampleContent = `
|
|
5
|
+
# Markdown Demo Page
|
|
6
|
+
|
|
7
|
+
Welcome to the **Markdown demo**! This page demonstrates Reroute's native markdown support with syntax highlighting.
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
Simply import the \`Markdown\` component and pass your content:
|
|
12
|
+
|
|
13
|
+
\`\`\`tsx
|
|
14
|
+
import { Markdown } from 'reroute-js/react';
|
|
15
|
+
|
|
16
|
+
<Markdown>
|
|
17
|
+
# Your content here
|
|
18
|
+
</Markdown>
|
|
19
|
+
\`\`\`
|
|
20
|
+
|
|
21
|
+
## Code Examples
|
|
22
|
+
|
|
23
|
+
### JavaScript
|
|
24
|
+
|
|
25
|
+
\`\`\`javascript
|
|
26
|
+
const greet = (name) => {
|
|
27
|
+
console.log(\`Hello, \${name}!\`);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
greet('Reroute');
|
|
31
|
+
\`\`\`
|
|
32
|
+
|
|
33
|
+
### TypeScript
|
|
34
|
+
|
|
35
|
+
\`\`\`typescript
|
|
36
|
+
interface Route {
|
|
37
|
+
path: string;
|
|
38
|
+
component: React.ComponentType;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const routes: Route[] = [
|
|
42
|
+
{ path: '/', component: HomePage },
|
|
43
|
+
{ path: '/blog', component: BlogPage },
|
|
44
|
+
];
|
|
45
|
+
\`\`\`
|
|
46
|
+
|
|
47
|
+
### JSON
|
|
48
|
+
|
|
49
|
+
\`\`\`json
|
|
50
|
+
{
|
|
51
|
+
"name": "reroute-app",
|
|
52
|
+
"version": "1.0.0",
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"react-markdown": "^10.1.0",
|
|
55
|
+
"shiki": "^3.14.0"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
\`\`\`
|
|
59
|
+
|
|
60
|
+
## Lists and Formatting
|
|
61
|
+
|
|
62
|
+
### Unordered List
|
|
63
|
+
- Item one
|
|
64
|
+
- Item two with **bold text**
|
|
65
|
+
- Item three with *italic text*
|
|
66
|
+
- Item four with \`inline code\`
|
|
67
|
+
|
|
68
|
+
### Ordered List
|
|
69
|
+
1. First step
|
|
70
|
+
2. Second step
|
|
71
|
+
3. Third step
|
|
72
|
+
|
|
73
|
+
### Task List
|
|
74
|
+
- [x] Add markdown support
|
|
75
|
+
- [x] Integrate Shiki
|
|
76
|
+
- [x] Create examples
|
|
77
|
+
- [ ] Add more themes
|
|
78
|
+
|
|
79
|
+
## Blockquotes
|
|
80
|
+
|
|
81
|
+
> "Markdown makes writing for the web easy and enjoyable."
|
|
82
|
+
> — Someone who loves markdown
|
|
83
|
+
|
|
84
|
+
## Tables
|
|
85
|
+
|
|
86
|
+
| Package | Purpose | Required |
|
|
87
|
+
|---------|---------|----------|
|
|
88
|
+
| react-markdown | Markdown renderer | ✅ Yes |
|
|
89
|
+
| remark-gfm | GitHub features | 🔶 Optional |
|
|
90
|
+
| shiki | Syntax highlighting | 🔶 Optional |
|
|
91
|
+
|
|
92
|
+
## Links and Emphasis
|
|
93
|
+
|
|
94
|
+
Check out the [Reroute documentation](https://github.com/stewones/reroute) for more info!
|
|
95
|
+
|
|
96
|
+
You can use **bold**, *italic*, ***bold and italic***, ~~strikethrough~~, and \`inline code\`.
|
|
97
|
+
|
|
98
|
+
## Horizontal Rule
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
That's all for this demo! 🚀
|
|
103
|
+
`;
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<main style={{ padding: '2rem', maxWidth: '900px', margin: '0 auto' }}>
|
|
107
|
+
<nav style={{ marginBottom: '2rem' }}>
|
|
108
|
+
<Link
|
|
109
|
+
to='/'
|
|
110
|
+
style={{
|
|
111
|
+
padding: '0.5rem 1rem',
|
|
112
|
+
background: '#0066cc',
|
|
113
|
+
color: '#fff',
|
|
114
|
+
textDecoration: 'none',
|
|
115
|
+
borderRadius: '4px',
|
|
116
|
+
display: 'inline-block',
|
|
117
|
+
}}
|
|
118
|
+
>
|
|
119
|
+
← Back to Home
|
|
120
|
+
</Link>
|
|
121
|
+
</nav>
|
|
122
|
+
|
|
123
|
+
<div
|
|
124
|
+
style={{
|
|
125
|
+
background: '#1e1e1e',
|
|
126
|
+
padding: '2rem',
|
|
127
|
+
borderRadius: '8px',
|
|
128
|
+
color: '#d4d4d4',
|
|
129
|
+
}}
|
|
130
|
+
>
|
|
131
|
+
<Markdown theme='github-dark' gfm={true} highlight={true}>
|
|
132
|
+
{exampleContent}
|
|
133
|
+
</Markdown>
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
<section
|
|
137
|
+
style={{
|
|
138
|
+
marginTop: '2rem',
|
|
139
|
+
padding: '1rem',
|
|
140
|
+
background: '#f0f9ff',
|
|
141
|
+
borderRadius: '8px',
|
|
142
|
+
border: '1px solid #bfdbfe',
|
|
143
|
+
}}
|
|
144
|
+
>
|
|
145
|
+
<h3 style={{ marginTop: 0, color: '#1e40af' }}>💡 Pro Tips</h3>
|
|
146
|
+
<ul style={{ color: '#1e3a8a' }}>
|
|
147
|
+
<li>
|
|
148
|
+
The Markdown component only bundles dependencies you actually use
|
|
149
|
+
</li>
|
|
150
|
+
<li>Shiki provides VS Code-quality syntax highlighting</li>
|
|
151
|
+
<li>
|
|
152
|
+
GitHub Flavored Markdown adds tables, task lists, and more (with
|
|
153
|
+
remark-gfm)
|
|
154
|
+
</li>
|
|
155
|
+
<li>Customize themes and components for your design system</li>
|
|
156
|
+
</ul>
|
|
157
|
+
</section>
|
|
158
|
+
</main>
|
|
159
|
+
);
|
|
160
|
+
}
|
package/_/blog/src/index.ts
CHANGED
|
@@ -12,9 +12,12 @@ const app = new Elysia()
|
|
|
12
12
|
minify: IS_PRODUCTION,
|
|
13
13
|
}),
|
|
14
14
|
)
|
|
15
|
-
.get('/message', () =>
|
|
15
|
+
.get('/message', () => {
|
|
16
|
+
console.log('[api] log from my api');
|
|
17
|
+
return { message: 'Hello from server' };
|
|
18
|
+
})
|
|
16
19
|
.listen(Number(Bun.env.PORT || '3000'));
|
|
17
20
|
|
|
18
21
|
console.log(
|
|
19
|
-
|
|
22
|
+
`[reroute] Blog running at ${app.server?.hostname}:${app.server?.port} on ${Bun.env.NODE_ENV || 'development'}`,
|
|
20
23
|
);
|
package/_/store/package.json
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
"description": "A Reroute store application with Tailwind CSS v4",
|
|
5
5
|
"private": true,
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"start": "reroute
|
|
9
|
-
"dev": "reroute
|
|
10
|
-
"build": "reroute
|
|
7
|
+
"types": "tsc --noEmit",
|
|
8
|
+
"start": "reroute start",
|
|
9
|
+
"dev": "reroute dev",
|
|
10
|
+
"build": "reroute build"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"reroute-js": "latest",
|
package/_/store/src/index.ts
CHANGED
|
@@ -16,5 +16,5 @@ const app = new Elysia()
|
|
|
16
16
|
.listen(Number(Bun.env.PORT || '3001'));
|
|
17
17
|
|
|
18
18
|
console.log(
|
|
19
|
-
|
|
19
|
+
`[reroute] Store running at ${app.server?.hostname}:${app.server?.port} on ${Bun.env.NODE_ENV || 'development'}`,
|
|
20
20
|
);
|
package/cli/bin.d.ts
CHANGED