reroute-js 0.4.4 → 0.6.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 +141 -0
- package/cli/bin.d.ts +1 -1
- package/cli/bin.js +513 -66
- package/cli/bin.js.map +6 -4
- package/cli/index.d.ts +1 -1
- package/cli/index.js +378 -16
- package/cli/index.js.map +5 -3
- package/cli/src/cli.d.ts +1 -1
- package/cli/src/commands/boot.d.ts +1 -1
- 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/libs/index.d.ts +3 -1
- package/cli/src/libs/index.d.ts.map +1 -1
- 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 +3 -3
- 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 +3 -3
- 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 +17 -9
- package/react/index.d.ts +1 -1
- package/react/index.js +163 -66
- package/react/index.js.map +7 -5
- package/react/src/components/ClientOnly.d.ts +31 -0
- package/react/src/components/ClientOnly.d.ts.map +1 -0
- 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 +3 -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/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/README.md
CHANGED
|
@@ -23,6 +23,17 @@ Reroute is a dead-simple file-based routing framework for building full-stack Re
|
|
|
23
23
|
- 🎯 **Dynamic Imports** - Code-split content chunks for optimal loading
|
|
24
24
|
- 📦 **Collection Chunking** - Individual module bundles per content item
|
|
25
25
|
|
|
26
|
+
### 📝 Markdown & MDX Support
|
|
27
|
+
- 📄 **Native Markdown Routes** - Drop `.md` or `.mdx` files directly in your routes directory
|
|
28
|
+
- 🎨 **Syntax Highlighting** - Beautiful code blocks powered by Shiki with VS Code themes
|
|
29
|
+
- 📋 **Frontmatter Support** - YAML frontmatter for page metadata (title, description, date, etc.)
|
|
30
|
+
- ⚛️ **True MDX Support** - Import and use React components inside markdown with `@mdx-js/mdx`
|
|
31
|
+
- 🧩 **Component Composition** - Mix JSX components with markdown content seamlessly
|
|
32
|
+
- 🔧 **Zero Config** - Automatic detection and processing when react-markdown is installed
|
|
33
|
+
- 🎯 **GitHub Flavored Markdown** - Tables, task lists, strikethrough with remark-gfm
|
|
34
|
+
- ⚡ **Optional Dependencies** - Only bundle what you use (markdown, GFM, Shiki, MDX)
|
|
35
|
+
- 🧩 **Markdown Component** - Programmatic markdown rendering with `<Markdown>` component
|
|
36
|
+
|
|
26
37
|
### ⚛️ React Integration
|
|
27
38
|
- ⚡ **React 19** - Built with the latest React version for optimal performance
|
|
28
39
|
- 🪝 **Router Hooks**:
|
|
@@ -158,6 +169,136 @@ Notes:
|
|
|
158
169
|
- Data is injected as `window.__REROUTE_DATA__` and read during hydration
|
|
159
170
|
- Use with existing content features (useContent); both can be seeded in the same page
|
|
160
171
|
|
|
172
|
+
## 📝 Markdown Routes
|
|
173
|
+
|
|
174
|
+
Reroute supports native markdown and MDX files as routes with frontmatter support and syntax highlighting.
|
|
175
|
+
|
|
176
|
+
### Installation
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Required for markdown support
|
|
180
|
+
bun add react-markdown
|
|
181
|
+
|
|
182
|
+
# Optional: GitHub Flavored Markdown (tables, task lists, etc.)
|
|
183
|
+
bun add remark-gfm
|
|
184
|
+
|
|
185
|
+
# Optional: Syntax highlighting with Shiki
|
|
186
|
+
bun add -d @shikijs/rehype
|
|
187
|
+
|
|
188
|
+
# Optional: MDX support (use React components in markdown)
|
|
189
|
+
bun add @mdx-js/mdx
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Creating Markdown Routes
|
|
193
|
+
|
|
194
|
+
Simply create `.md` files in your routes directory:
|
|
195
|
+
|
|
196
|
+
```markdown
|
|
197
|
+
<!-- src/client/routes/about.md -->
|
|
198
|
+
---
|
|
199
|
+
title: About Us
|
|
200
|
+
description: Learn more about our company
|
|
201
|
+
date: 2025-01-15
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
# About Us
|
|
205
|
+
|
|
206
|
+
Welcome to our **amazing** company! We build great things.
|
|
207
|
+
|
|
208
|
+
## Our Mission
|
|
209
|
+
|
|
210
|
+
We strive to create the best developer experience possible.
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
// Example code block with syntax highlighting
|
|
214
|
+
const greeting = "Hello, World!";
|
|
215
|
+
console.log(greeting);
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Check out our [documentation](/docs) for more info!
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
The route will be automatically available at `/about` with:
|
|
222
|
+
- Automatic `<title>` and `<meta>` tag generation from frontmatter
|
|
223
|
+
- Syntax highlighting for code blocks (if Shiki is installed)
|
|
224
|
+
- GitHub Flavored Markdown support (if remark-gfm is installed)
|
|
225
|
+
|
|
226
|
+
### Creating MDX Routes with Components
|
|
227
|
+
|
|
228
|
+
For interactive content with React components, use `.mdx` files:
|
|
229
|
+
|
|
230
|
+
```mdx
|
|
231
|
+
<!-- src/client/routes/interactive.mdx -->
|
|
232
|
+
---
|
|
233
|
+
title: Interactive Demo
|
|
234
|
+
description: MDX with React components
|
|
235
|
+
date: 2025-01-17
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
import { Link } from 'reroute-js/react';
|
|
239
|
+
import { useState } from 'react';
|
|
240
|
+
|
|
241
|
+
# Interactive Content
|
|
242
|
+
|
|
243
|
+
This page uses React components!
|
|
244
|
+
|
|
245
|
+
export function Counter() {
|
|
246
|
+
const [count, setCount] = useState(0);
|
|
247
|
+
return (
|
|
248
|
+
<div>
|
|
249
|
+
<p>Count: {count}</p>
|
|
250
|
+
<button onClick={() => setCount(count + 1)}>
|
|
251
|
+
Increment
|
|
252
|
+
</button>
|
|
253
|
+
</div>
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
<Counter />
|
|
258
|
+
|
|
259
|
+
You can also use imported components:
|
|
260
|
+
|
|
261
|
+
<Link to="/">Go Home</Link>
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**MDX Support requires:**
|
|
265
|
+
- `@mdx-js/mdx` package installed
|
|
266
|
+
- `.mdx` file extension
|
|
267
|
+
- React components imported at the top
|
|
268
|
+
|
|
269
|
+
### Programmatic Markdown Rendering
|
|
270
|
+
|
|
271
|
+
Use the `<Markdown>` component to render markdown content dynamically:
|
|
272
|
+
|
|
273
|
+
```tsx
|
|
274
|
+
import { Markdown } from 'reroute-js/react';
|
|
275
|
+
|
|
276
|
+
export default function MyPage() {
|
|
277
|
+
const content = `# Hello\nThis is **markdown** content.`;
|
|
278
|
+
|
|
279
|
+
return (
|
|
280
|
+
<Markdown
|
|
281
|
+
theme="github-dark"
|
|
282
|
+
gfm={true}
|
|
283
|
+
highlight={true}
|
|
284
|
+
>
|
|
285
|
+
{content}
|
|
286
|
+
</Markdown>
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Features
|
|
292
|
+
|
|
293
|
+
- **Frontmatter**: YAML metadata for SEO and content organization
|
|
294
|
+
- **Syntax Highlighting**: Powered by Shiki via @shikijs/rehype with VS Code themes
|
|
295
|
+
- **GFM Support**: Tables, task lists, strikethrough, autolinks
|
|
296
|
+
- **MDX Support**: Import and use React components in `.mdx` files
|
|
297
|
+
- **Component Composition**: Mix markdown with JSX seamlessly
|
|
298
|
+
- **Type Safety**: Full TypeScript support
|
|
299
|
+
- **Zero Config**: Automatic detection when packages are installed
|
|
300
|
+
- **Optional**: Only bundle dependencies you actually use
|
|
301
|
+
|
|
161
302
|
|
|
162
303
|
## 📖 Learn More
|
|
163
304
|
|
package/cli/bin.d.ts
CHANGED