reroute-js 0.5.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 +142 -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 +1313 -74
- package/cli/bin.js.map +13 -7
- package/cli/index.d.ts +1 -1
- package/cli/index.js +428 -17
- package/cli/index.js.map +6 -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/gen.d.ts.map +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 +4 -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 +59 -0
- package/cli/src/libs/markdown-processor.d.ts.map +1 -0
- package/cli/src/libs/markdown.d.ts +33 -0
- package/cli/src/libs/markdown.d.ts.map +1 -0
- 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 +4 -4
- package/core/index.js.map +2 -2
- 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 +4 -4
- package/elysia/index.js.map +2 -2
- 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 +22 -9
- package/react/index.d.ts +1 -1
- package/react/index.js +141 -36
- package/react/index.js.map +7 -6
- package/react/src/components/ClientOnly.d.ts +1 -1
- package/react/src/components/ContentRoute.d.ts +1 -1
- package/react/src/components/ContentRoute.d.ts.map +1 -1
- package/react/src/components/Image.d.ts +1 -1
- package/react/src/components/Link.d.ts +1 -1
- package/react/src/components/Link.d.ts.map +1 -1
- package/react/src/components/Markdown.d.ts +89 -0
- package/react/src/components/Markdown.d.ts.map +1 -0
- package/react/src/components/Outlet.d.ts +1 -1
- package/react/src/components/index.d.ts +2 -1
- package/react/src/components/index.d.ts.map +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
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ Reroute is a dead-simple file-based routing framework for building full-stack Re
|
|
|
14
14
|
### 🛠️ CLI Tools
|
|
15
15
|
- 🚀 **`reroute init`** - Scaffold new projects with templates (basic, blog, store)
|
|
16
16
|
- 🔨 **`reroute gen`** - Generate content registry and route artifacts
|
|
17
|
+
- ⚡ **`reroute dev`** - Start development environment with side-by-side logs and colored output
|
|
17
18
|
|
|
18
19
|
### 📄 Content Management
|
|
19
20
|
- 📚 **Content Collections** - Organize content by collections (blog posts, docs, etc.)
|
|
@@ -23,6 +24,17 @@ Reroute is a dead-simple file-based routing framework for building full-stack Re
|
|
|
23
24
|
- 🎯 **Dynamic Imports** - Code-split content chunks for optimal loading
|
|
24
25
|
- 📦 **Collection Chunking** - Individual module bundles per content item
|
|
25
26
|
|
|
27
|
+
### 📝 Markdown & MDX Support
|
|
28
|
+
- 📄 **Native Markdown Routes** - Drop `.md` or `.mdx` files directly in your routes directory
|
|
29
|
+
- 🎨 **Syntax Highlighting** - Beautiful code blocks powered by Shiki with VS Code themes
|
|
30
|
+
- 📋 **Frontmatter Support** - YAML frontmatter for page metadata (title, description, date, etc.)
|
|
31
|
+
- ⚛️ **True MDX Support** - Import and use React components inside markdown with `@mdx-js/mdx`
|
|
32
|
+
- 🧩 **Component Composition** - Mix JSX components with markdown content seamlessly
|
|
33
|
+
- 🔧 **Zero Config** - Automatic detection and processing when react-markdown is installed
|
|
34
|
+
- 🎯 **GitHub Flavored Markdown** - Tables, task lists, strikethrough with remark-gfm
|
|
35
|
+
- ⚡ **Optional Dependencies** - Only bundle what you use (markdown, GFM, Shiki, MDX)
|
|
36
|
+
- 🧩 **Markdown Component** - Programmatic markdown rendering with `<Markdown>` component
|
|
37
|
+
|
|
26
38
|
### ⚛️ React Integration
|
|
27
39
|
- ⚡ **React 19** - Built with the latest React version for optimal performance
|
|
28
40
|
- 🪝 **Router Hooks**:
|
|
@@ -158,6 +170,136 @@ Notes:
|
|
|
158
170
|
- Data is injected as `window.__REROUTE_DATA__` and read during hydration
|
|
159
171
|
- Use with existing content features (useContent); both can be seeded in the same page
|
|
160
172
|
|
|
173
|
+
## 📝 Markdown Routes
|
|
174
|
+
|
|
175
|
+
Reroute supports native markdown and MDX files as routes with frontmatter support and syntax highlighting.
|
|
176
|
+
|
|
177
|
+
### Installation
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# Required for markdown support
|
|
181
|
+
bun add react-markdown
|
|
182
|
+
|
|
183
|
+
# Optional: GitHub Flavored Markdown (tables, task lists, etc.)
|
|
184
|
+
bun add remark-gfm
|
|
185
|
+
|
|
186
|
+
# Optional: Syntax highlighting with Shiki
|
|
187
|
+
bun add -d @shikijs/rehype
|
|
188
|
+
|
|
189
|
+
# Optional: MDX support (use React components in markdown)
|
|
190
|
+
bun add @mdx-js/mdx
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Creating Markdown Routes
|
|
194
|
+
|
|
195
|
+
Simply create `.md` files in your routes directory:
|
|
196
|
+
|
|
197
|
+
```markdown
|
|
198
|
+
<!-- src/client/routes/about.md -->
|
|
199
|
+
---
|
|
200
|
+
title: About Us
|
|
201
|
+
description: Learn more about our company
|
|
202
|
+
date: 2025-01-15
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
# About Us
|
|
206
|
+
|
|
207
|
+
Welcome to our **amazing** company! We build great things.
|
|
208
|
+
|
|
209
|
+
## Our Mission
|
|
210
|
+
|
|
211
|
+
We strive to create the best developer experience possible.
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
// Example code block with syntax highlighting
|
|
215
|
+
const greeting = "Hello, World!";
|
|
216
|
+
console.log(greeting);
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Check out our [documentation](/docs) for more info!
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
The route will be automatically available at `/about` with:
|
|
223
|
+
- Automatic `<title>` and `<meta>` tag generation from frontmatter
|
|
224
|
+
- Syntax highlighting for code blocks (if Shiki is installed)
|
|
225
|
+
- GitHub Flavored Markdown support (if remark-gfm is installed)
|
|
226
|
+
|
|
227
|
+
### Creating MDX Routes with Components
|
|
228
|
+
|
|
229
|
+
For interactive content with React components, use `.mdx` files:
|
|
230
|
+
|
|
231
|
+
```mdx
|
|
232
|
+
<!-- src/client/routes/interactive.mdx -->
|
|
233
|
+
---
|
|
234
|
+
title: Interactive Demo
|
|
235
|
+
description: MDX with React components
|
|
236
|
+
date: 2025-01-17
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
import { Link } from 'reroute-js/react';
|
|
240
|
+
import { useState } from 'react';
|
|
241
|
+
|
|
242
|
+
# Interactive Content
|
|
243
|
+
|
|
244
|
+
This page uses React components!
|
|
245
|
+
|
|
246
|
+
export function Counter() {
|
|
247
|
+
const [count, setCount] = useState(0);
|
|
248
|
+
return (
|
|
249
|
+
<div>
|
|
250
|
+
<p>Count: {count}</p>
|
|
251
|
+
<button onClick={() => setCount(count + 1)}>
|
|
252
|
+
Increment
|
|
253
|
+
</button>
|
|
254
|
+
</div>
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
<Counter />
|
|
259
|
+
|
|
260
|
+
You can also use imported components:
|
|
261
|
+
|
|
262
|
+
<Link to="/">Go Home</Link>
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
**MDX Support requires:**
|
|
266
|
+
- `@mdx-js/mdx` package installed
|
|
267
|
+
- `.mdx` file extension
|
|
268
|
+
- React components imported at the top
|
|
269
|
+
|
|
270
|
+
### Programmatic Markdown Rendering
|
|
271
|
+
|
|
272
|
+
Use the `<Markdown>` component to render markdown content dynamically:
|
|
273
|
+
|
|
274
|
+
```tsx
|
|
275
|
+
import { Markdown } from 'reroute-js/react';
|
|
276
|
+
|
|
277
|
+
export default function MyPage() {
|
|
278
|
+
const content = `# Hello\nThis is **markdown** content.`;
|
|
279
|
+
|
|
280
|
+
return (
|
|
281
|
+
<Markdown
|
|
282
|
+
theme="github-dark"
|
|
283
|
+
gfm={true}
|
|
284
|
+
highlight={true}
|
|
285
|
+
>
|
|
286
|
+
{content}
|
|
287
|
+
</Markdown>
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Features
|
|
293
|
+
|
|
294
|
+
- **Frontmatter**: YAML metadata for SEO and content organization
|
|
295
|
+
- **Syntax Highlighting**: Powered by Shiki via @shikijs/rehype with VS Code themes
|
|
296
|
+
- **GFM Support**: Tables, task lists, strikethrough, autolinks
|
|
297
|
+
- **MDX Support**: Import and use React components in `.mdx` files
|
|
298
|
+
- **Component Composition**: Mix markdown with JSX seamlessly
|
|
299
|
+
- **Type Safety**: Full TypeScript support
|
|
300
|
+
- **Zero Config**: Automatic detection when packages are installed
|
|
301
|
+
- **Optional**: Only bundle dependencies you actually use
|
|
302
|
+
|
|
161
303
|
|
|
162
304
|
## 📖 Learn More
|
|
163
305
|
|
package/_/basic/package.json
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
"description": "A Reroute application",
|
|
4
4
|
"version": "0.0.0",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"
|
|
7
|
-
"start": "reroute
|
|
8
|
-
"dev": "reroute
|
|
9
|
-
"build": "reroute
|
|
6
|
+
"types": "tsc --noEmit",
|
|
7
|
+
"start": "reroute start",
|
|
8
|
+
"dev": "reroute dev",
|
|
9
|
+
"build": "reroute build"
|
|
10
10
|
},
|
|
11
11
|
"private": true,
|
|
12
12
|
"dependencies": {
|
package/_/basic/src/index.ts
CHANGED
|
@@ -15,6 +15,4 @@ const app = new Elysia()
|
|
|
15
15
|
.get('/api/message', () => ({ message: 'Hello from server' }))
|
|
16
16
|
.listen(Number(Bun.env.PORT || '3000'));
|
|
17
17
|
|
|
18
|
-
console.log(
|
|
19
|
-
`🦊 Reroute is running at ${app.server?.hostname}:${app.server?.port}`,
|
|
20
|
-
);
|
|
18
|
+
console.log(`[reroute] Running at ${app.server?.hostname}:${app.server?.port}`);
|
package/_/blog/package.json
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
"description": "A Reroute application",
|
|
4
4
|
"version": "0.0.0",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"
|
|
7
|
-
"start": "reroute
|
|
8
|
-
"dev": "reroute
|
|
9
|
-
"build": "reroute
|
|
6
|
+
"types": "tsc --noEmit",
|
|
7
|
+
"start": "reroute start",
|
|
8
|
+
"dev": "reroute dev",
|
|
9
|
+
"build": "reroute build"
|
|
10
10
|
},
|
|
11
11
|
"private": true,
|
|
12
12
|
"dependencies": {
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Markdown with Syntax Highlighting
|
|
3
|
+
description: Learn how to use markdown with beautiful syntax highlighting powered by Shiki
|
|
4
|
+
excerpt: A complete guide to using markdown in Reroute with Shiki syntax highlighting
|
|
5
|
+
date: 2025-11-04
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Markdown with Syntax Highlighting
|
|
9
|
+
|
|
10
|
+
Reroute now supports **native markdown rendering** with beautiful syntax highlighting powered by [Shiki](https://shiki.style/)!
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- ✅ **GitHub Flavored Markdown** - Tables, task lists, strikethrough, and more
|
|
15
|
+
- ✅ **Syntax Highlighting** - Powered by Shiki with VS Code themes
|
|
16
|
+
- ✅ **Zero Config** - Works out of the box when packages are installed
|
|
17
|
+
- ✅ **Optional** - Only included when you need it
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
To use markdown in your Reroute project:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Required: Markdown renderer
|
|
25
|
+
bun add react-markdown
|
|
26
|
+
|
|
27
|
+
# Optional: GitHub Flavored Markdown support
|
|
28
|
+
bun add remark-gfm
|
|
29
|
+
|
|
30
|
+
# Optional: Syntax highlighting
|
|
31
|
+
bun add -d @shikijs/rehype
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Basic Usage
|
|
35
|
+
|
|
36
|
+
Import the Markdown component and pass your content as children:
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import { Markdown } from 'reroute-js/react';
|
|
40
|
+
|
|
41
|
+
export default function MyPost() {
|
|
42
|
+
return (
|
|
43
|
+
<Markdown>
|
|
44
|
+
{/* Your markdown content here */}
|
|
45
|
+
# Hello World
|
|
46
|
+
This is **bold** and this is *italic*.
|
|
47
|
+
</Markdown>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Code Highlighting
|
|
53
|
+
|
|
54
|
+
Shiki provides beautiful syntax highlighting for many languages:
|
|
55
|
+
|
|
56
|
+
### TypeScript Example
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
interface User {
|
|
60
|
+
id: number;
|
|
61
|
+
name: string;
|
|
62
|
+
email: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function fetchUser(id: number): Promise<User> {
|
|
66
|
+
const response = await fetch(`/api/users/${id}`);
|
|
67
|
+
return response.json();
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### React Component
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
import { useState } from 'react';
|
|
75
|
+
import { Link } from 'reroute-js/react';
|
|
76
|
+
|
|
77
|
+
export default function Counter() {
|
|
78
|
+
const [count, setCount] = useState(0);
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div>
|
|
82
|
+
<h2>Count: {count}</h2>
|
|
83
|
+
<button onClick={() => setCount(count + 1)}>
|
|
84
|
+
Increment
|
|
85
|
+
</button>
|
|
86
|
+
<Link to="/">Home</Link>
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Python Example
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
def fibonacci(n: int) -> list[int]:
|
|
96
|
+
"""Generate fibonacci sequence up to n terms."""
|
|
97
|
+
if n <= 0:
|
|
98
|
+
return []
|
|
99
|
+
elif n == 1:
|
|
100
|
+
return [0]
|
|
101
|
+
|
|
102
|
+
sequence = [0, 1]
|
|
103
|
+
for i in range(2, n):
|
|
104
|
+
sequence.append(sequence[i-1] + sequence[i-2])
|
|
105
|
+
|
|
106
|
+
return sequence
|
|
107
|
+
|
|
108
|
+
# Generate first 10 fibonacci numbers
|
|
109
|
+
print(fibonacci(10))
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## GitHub Flavored Markdown
|
|
113
|
+
|
|
114
|
+
With `remark-gfm`, you get additional features:
|
|
115
|
+
|
|
116
|
+
### Tables
|
|
117
|
+
|
|
118
|
+
| Feature | Status | Notes |
|
|
119
|
+
|---------|--------|-------|
|
|
120
|
+
| Markdown | ✅ | react-markdown |
|
|
121
|
+
| Syntax Highlighting | ✅ | Shiki |
|
|
122
|
+
| GFM Support | ✅ | remark-gfm |
|
|
123
|
+
| Auto Detection | ✅ | CLI integration |
|
|
124
|
+
|
|
125
|
+
### Task Lists
|
|
126
|
+
|
|
127
|
+
- [x] Install react-markdown
|
|
128
|
+
- [x] Add optional Shiki support
|
|
129
|
+
- [x] Create example blog post
|
|
130
|
+
- [ ] Write more documentation
|
|
131
|
+
|
|
132
|
+
### Strikethrough
|
|
133
|
+
|
|
134
|
+
~~This is outdated information~~ Use the new Markdown component instead!
|
|
135
|
+
|
|
136
|
+
### Autolinks
|
|
137
|
+
|
|
138
|
+
Check out the docs at https://github.com/stewones/reroute
|
|
139
|
+
|
|
140
|
+
## Advanced Configuration
|
|
141
|
+
|
|
142
|
+
You can customize the Markdown component with various options:
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
<Markdown
|
|
146
|
+
theme="github-light"
|
|
147
|
+
gfm={true}
|
|
148
|
+
highlight={true}
|
|
149
|
+
className="prose prose-slate"
|
|
150
|
+
>
|
|
151
|
+
{markdownContent}
|
|
152
|
+
</Markdown>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Custom Components
|
|
156
|
+
|
|
157
|
+
Override default HTML elements with your own components:
|
|
158
|
+
|
|
159
|
+
```tsx
|
|
160
|
+
<Markdown
|
|
161
|
+
components={{
|
|
162
|
+
h1: ({ children }) => (
|
|
163
|
+
<h1 className="text-4xl font-bold mb-4">
|
|
164
|
+
{children}
|
|
165
|
+
</h1>
|
|
166
|
+
),
|
|
167
|
+
a: ({ href, children }) => (
|
|
168
|
+
<Link to={href} className="text-blue-500 hover:underline">
|
|
169
|
+
{children}
|
|
170
|
+
</Link>
|
|
171
|
+
),
|
|
172
|
+
}}
|
|
173
|
+
>
|
|
174
|
+
{content}
|
|
175
|
+
</Markdown>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Performance
|
|
179
|
+
|
|
180
|
+
The Markdown component uses dynamic imports to avoid bundling dependencies you don't need:
|
|
181
|
+
|
|
182
|
+
- **react-markdown**: Only loaded if you use the component
|
|
183
|
+
- **remark-gfm**: Only loaded if GFM features are enabled
|
|
184
|
+
- **shiki**: Only loaded if syntax highlighting is enabled
|
|
185
|
+
|
|
186
|
+
This keeps your bundle size minimal! 📦
|
|
187
|
+
|
|
188
|
+
## Integration with Content Collections
|
|
189
|
+
|
|
190
|
+
Markdown works seamlessly with Reroute's content system:
|
|
191
|
+
|
|
192
|
+
```tsx
|
|
193
|
+
import { useContent } from 'reroute-js/react';
|
|
194
|
+
import { Markdown } from 'reroute-js/react';
|
|
195
|
+
|
|
196
|
+
export default function BlogPost() {
|
|
197
|
+
const posts = useContent('blog');
|
|
198
|
+
const post = posts[0];
|
|
199
|
+
|
|
200
|
+
return (
|
|
201
|
+
<article>
|
|
202
|
+
<h1>{post.meta.title}</h1>
|
|
203
|
+
<Markdown>{post.content}</Markdown>
|
|
204
|
+
</article>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Conclusion
|
|
210
|
+
|
|
211
|
+
With markdown support, Reroute makes it easy to create content-rich applications with beautiful code examples. The optional nature of the dependencies means you only pay for what you use!
|
|
212
|
+
|
|
213
|
+
Happy writing! 🎉
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Content in Markdown
|
|
3
|
+
description: Learn how to use markdown files in Reroute content collections for easy blog authoring
|
|
4
|
+
date: 2025-11-05
|
|
5
|
+
excerpt: Markdown files work seamlessly in content collections - no JSX needed!
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Writing Blog Posts in Markdown
|
|
9
|
+
|
|
10
|
+
This blog post is written entirely in **markdown** and lives in the `content/` directory as a `.md` file. No JSX, no React components - just pure markdown!
|
|
11
|
+
|
|
12
|
+
## Content Collections + Markdown
|
|
13
|
+
|
|
14
|
+
Reroute's content system now supports markdown files natively. Simply drop a `.md` or `.mdx` file in your content collection directory:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
src/client/routes/blog/content/
|
|
18
|
+
├── 1-hello-world.tsx # Traditional TSX
|
|
19
|
+
├── 2-what-is-reroute.tsx # Traditional TSX
|
|
20
|
+
├── 3-markdown-with-syntax.tsx # TSX with Markdown component
|
|
21
|
+
└── 4-content-in-markdown.md # 🎉 Pure markdown!
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## The Best of Both Worlds
|
|
25
|
+
|
|
26
|
+
You get all the benefits of content collections:
|
|
27
|
+
|
|
28
|
+
✅ **Automatic indexing** - Appears in `useContent('blog')`
|
|
29
|
+
✅ **Frontmatter metadata** - Title, description, date, etc.
|
|
30
|
+
✅ **Type-safe routing** - Works with `<ContentRoute>`
|
|
31
|
+
✅ **Code splitting** - Individual chunk per post
|
|
32
|
+
✅ **Syntax highlighting** - Beautiful code blocks with Shiki
|
|
33
|
+
|
|
34
|
+
But with the simplicity of markdown authoring!
|
|
35
|
+
|
|
36
|
+
## Writing Content
|
|
37
|
+
|
|
38
|
+
### Headings and Text
|
|
39
|
+
|
|
40
|
+
Use standard markdown syntax. Text can be **bold**, *italic*, or ***both***. You can also use ~~strikethrough~~ and `inline code`.
|
|
41
|
+
|
|
42
|
+
### Code Blocks
|
|
43
|
+
|
|
44
|
+
Syntax highlighting works automatically:
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { useContent } from 'reroute-js/react';
|
|
48
|
+
|
|
49
|
+
export default function BlogIndex() {
|
|
50
|
+
const posts = useContent('blog');
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<div>
|
|
54
|
+
{posts.map(post => (
|
|
55
|
+
<article key={post.slug}>
|
|
56
|
+
<h2>{post.meta.title}</h2>
|
|
57
|
+
<p>{post.meta.excerpt}</p>
|
|
58
|
+
</article>
|
|
59
|
+
))}
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```javascript
|
|
66
|
+
// Works with any language
|
|
67
|
+
const greet = (name) => {
|
|
68
|
+
console.log(`Hello, ${name}!`);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
greet('Markdown');
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Lists
|
|
75
|
+
|
|
76
|
+
**Task lists:**
|
|
77
|
+
- [x] Add markdown support to routes
|
|
78
|
+
- [x] Add markdown support to content collections
|
|
79
|
+
- [x] Write example blog post
|
|
80
|
+
- [ ] Write more posts!
|
|
81
|
+
|
|
82
|
+
**Regular lists:**
|
|
83
|
+
1. Write your post in markdown
|
|
84
|
+
2. Save it to the content directory
|
|
85
|
+
3. Run `reroute gen`
|
|
86
|
+
4. Your post is live!
|
|
87
|
+
|
|
88
|
+
### Tables
|
|
89
|
+
|
|
90
|
+
| Feature | Markdown | TSX |
|
|
91
|
+
|---------|----------|-----|
|
|
92
|
+
| Syntax | Simple | Verbose |
|
|
93
|
+
| Learning Curve | Easy | React knowledge needed |
|
|
94
|
+
| Flexibility | Good | Excellent |
|
|
95
|
+
| Speed | Fast | Fast |
|
|
96
|
+
|
|
97
|
+
### Blockquotes
|
|
98
|
+
|
|
99
|
+
> "Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format."
|
|
100
|
+
> — John Gruber, creator of Markdown
|
|
101
|
+
|
|
102
|
+
## How It Works
|
|
103
|
+
|
|
104
|
+
When you run `reroute gen`:
|
|
105
|
+
|
|
106
|
+
1. The CLI scans for markdown files in content directories
|
|
107
|
+
2. Parses frontmatter for metadata
|
|
108
|
+
3. Converts to a React component wrapper
|
|
109
|
+
4. Builds it like any other content file
|
|
110
|
+
5. Available via `useContent()` or `<ContentRoute>`
|
|
111
|
+
|
|
112
|
+
## When to Use Markdown
|
|
113
|
+
|
|
114
|
+
**Use markdown files when:**
|
|
115
|
+
- ✅ Writing blog posts or articles
|
|
116
|
+
- ✅ Creating documentation
|
|
117
|
+
- ✅ Content-focused pages
|
|
118
|
+
- ✅ Quick authoring without React complexity
|
|
119
|
+
|
|
120
|
+
**Use TSX files when:**
|
|
121
|
+
- 🎯 Need custom components or interactivity
|
|
122
|
+
- 🎯 Complex layouts or data fetching
|
|
123
|
+
- 🎯 Dynamic content with state management
|
|
124
|
+
- 🎯 Integration with external APIs
|
|
125
|
+
|
|
126
|
+
## Mixing and Matching
|
|
127
|
+
|
|
128
|
+
The beauty of Reroute is that you can mix both approaches:
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
blog/content/
|
|
132
|
+
├── simple-post.md # Pure markdown
|
|
133
|
+
├── interactive-demo.tsx # Full React component
|
|
134
|
+
└── hybrid-post.mdx # Markdown with JSX (coming soon!)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Use the right tool for each piece of content!
|
|
138
|
+
|
|
139
|
+
## Conclusion
|
|
140
|
+
|
|
141
|
+
Markdown support in content collections makes Reroute even more powerful for content-driven sites. Write your content in the format that makes sense for each piece.
|
|
142
|
+
|
|
143
|
+
Happy blogging! 🚀
|