@intlayer/docs 8.10.0-canary.0 → 8.10.0-canary.1

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.
@@ -135,11 +135,17 @@ You can declare Markdown content using the `md` function or simply as a string (
135
135
 
136
136
  ## Rendering Markdown
137
137
 
138
- Rendering can be handled automatically by Intlayer's content system or manually using specialized tools.
138
+ Intlayer provides two independent ways to render Markdown:
139
139
 
140
- ### 1. Automatic Rendering (using `useIntlayer`)
140
+ 1. **Via `useIntlayer`**
141
+ — Intlayer automatically transforms the `md` node into the framework's native output (JSX, VNode, HTML string).
142
+ - Frontmatter is parsed and exposed as `.metadata`. You can override rendering at two levels — globally with `MarkdownProvider` (or the framework equivalent) and locally per-node with `.use()`. Both can be combined; `.use()` takes priority over `MarkdownProvider`, which takes priority over the default.
141
143
 
142
- When you access content via `useIntlayer`, Markdown nodes are already prepared for rendering.
144
+ 2. **Helper utilities** `<MarkdownRenderer />`, `useMarkdownRenderer()`, and `renderMarkdown()` are standalone tools that accept **raw Markdown strings only**. They are independent of `useIntlayer` and do not work with the decorated nodes it returns.
145
+
146
+ Markdown rendering supports **MDX** — use any JSX/framework component by name directly in your Markdown.
147
+
148
+ ### 1. Automatic Rendering (via `useIntlayer`)
143
149
 
144
150
  <Tabs group="framework">
145
151
  <Tab label="React / Next.js" value="react">
@@ -147,21 +153,51 @@ When you access content via `useIntlayer`, Markdown nodes are already prepared f
147
153
 
148
154
  ```tsx fileName="App.tsx"
149
155
  import { useIntlayer } from "react-intlayer";
156
+ import { MarkdownProvider } from "react-intlayer/markdown";
150
157
 
151
158
  const AppContent = () => {
152
159
  const { myMarkdownContent } = useIntlayer("app");
160
+
153
161
  return <div>{myMarkdownContent}</div>;
154
162
  };
163
+
164
+ const App = () => (
165
+ <MarkdownProvider
166
+ components={{
167
+ h1: ({ children }) => <h1 style={{ color: "red" }}>{children}</h1>,
168
+ MyButton: (props) => <button {...props} />, // MDX component
169
+ }}
170
+ >
171
+ <AppContent />
172
+ </MarkdownProvider>
173
+ );
155
174
  ```
156
175
 
176
+ > If `MarkdownProvider` not present, intlayer will render the markdown using the default Markdown to JSX parser.
177
+
157
178
  You can also provide local overrides for specific nodes using the `.use()` method:
158
179
 
159
180
  ```tsx
160
181
  {myMarkdownContent.use({
161
- h1: ({ children }) => <h1 className="text-3xl font-bold">{children}</h1>,
182
+ h1: ({ children }) => <h1 style={{ color: "red" }}>{children}</h1>,
162
183
  })}
163
184
  ```
164
185
 
186
+ You can retrieve the Markdown as string:
187
+
188
+ ```tsx
189
+ {myMarkdownContent.value}
190
+ {String(myMarkdownContent)}
191
+ {myMarkdownContent.toString()}
192
+ ```
193
+
194
+ And you can access your markdown metadata like :
195
+
196
+ ```tsx
197
+ {myMarkdownContent.metadata}
198
+ {myMarkdownContent.metadata.title}
199
+ ```
200
+
165
201
  </Tab>
166
202
  <Tab label="Vue" value="vue">
167
203
  In Vue, Markdown content can be rendered using the `component` built-in or directly as a node.
@@ -177,43 +213,183 @@ When you access content via `useIntlayer`, Markdown nodes are already prepared f
177
213
  </template>
178
214
  ```
179
215
 
216
+ Configure globally via the `intlayerMarkdown` plugin (supports MDX custom components):
217
+
218
+ ```ts fileName="main.ts"
219
+ import { intlayerMarkdown } from "vue-intlayer/markdown";
220
+
221
+ app.use(intlayerMarkdown, {
222
+ components: {
223
+ h1: (props) => h('h1', { style: { color: 'green' } }, props.children),
224
+ MyButton: (props) => h('button', props), // MDX component
225
+ },
226
+ });
227
+ ```
228
+
229
+ > If the `intlayerMarkdown` plugin is not installed, Intlayer will render using the default compiler.
230
+
231
+ You can also provide local overrides for specific nodes using the `.use()` method:
232
+
233
+ ```vue
234
+ <component :is="myMarkdownContent.use({
235
+ h1: (props) => h('h1', { style: { color: 'red' } }, props.children),
236
+ })" />
237
+ ```
238
+
239
+ You can retrieve the Markdown as string:
240
+
241
+ ```vue
242
+ {{ myMarkdownContent.value }}
243
+ {{ String(myMarkdownContent) }}
244
+ {{ myMarkdownContent.toString() }}
245
+ ```
246
+
247
+ And you can access your markdown metadata like :
248
+
249
+ ```vue
250
+ <component :is="myMarkdownContent.metadata" />
251
+ <component :is="myMarkdownContent.metadata.title" />
252
+ ```
253
+
180
254
  </Tab>
181
255
  <Tab label="Svelte" value="svelte">
182
256
  Svelte renders Markdown as an HTML string by default. Use `{@html}` to render it.
183
257
 
184
- ```svelte
258
+ ```svelte fileName="App.svelte"
185
259
  <script lang="ts">
186
260
  import { useIntlayer } from "svelte-intlayer";
261
+ import { MarkdownProvider } from "svelte-intlayer/markdown";
262
+ import MyHeading from "./MyHeading.svelte";
263
+
187
264
  const content = useIntlayer("app");
188
265
  </script>
189
266
 
190
- {@html $content.myMarkdownContent}
267
+ <MarkdownProvider components={{ h1: MyHeading }}>
268
+ {@html $content.myMarkdownContent}
269
+ </MarkdownProvider>
270
+ ```
271
+
272
+ > If `MarkdownProvider` is not present, Intlayer will render the markdown using the default compiler.
273
+
274
+ You can also provide local overrides for specific nodes using the `.use()` method:
275
+
276
+ ```svelte
277
+ {@html $content.myMarkdownContent.use({ ... })}
278
+ ```
279
+
280
+ You can retrieve the Markdown as string:
281
+
282
+ ```svelte
283
+ {$content.myMarkdownContent.value}
284
+ {String($content.myMarkdownContent)}
285
+ {$content.myMarkdownContent.toString()}
286
+ ```
287
+
288
+ And you can access your markdown metadata like :
289
+
290
+ ```svelte
291
+ {$content.myMarkdownContent.metadata}
292
+ {$content.myMarkdownContent.metadata.title}
191
293
  ```
192
294
 
193
295
  </Tab>
194
296
  <Tab label="Preact" value="preact">
195
- Preact supports Markdown nodes directly in the JSX.
297
+ Preact supports Markdown nodes directly in JSX.
196
298
 
197
299
  ```tsx fileName="App.tsx"
198
300
  import { useIntlayer } from "preact-intlayer";
301
+ import { MarkdownProvider } from "preact-intlayer/markdown";
199
302
 
200
303
  const AppContent = () => {
201
304
  const { myMarkdownContent } = useIntlayer("app");
202
305
  return <div>{myMarkdownContent}</div>;
203
306
  };
307
+
308
+ const App = () => (
309
+ <MarkdownProvider
310
+ components={{
311
+ h1: ({ children }) => <h1 style={{ color: "red" }}>{children}</h1>,
312
+ MyButton: (props) => <button {...props} />, // MDX component
313
+ }}
314
+ >
315
+ <AppContent />
316
+ </MarkdownProvider>
317
+ );
318
+ ```
319
+
320
+ > If `MarkdownProvider` not present, intlayer will render the markdown using the default Markdown to JSX parser.
321
+
322
+ You can also provide local overrides for specific nodes using the `.use()` method:
323
+
324
+ ```tsx
325
+ {myMarkdownContent.use({
326
+ h1: ({ children }) => <h1 style={{ color: "red" }}>{children}</h1>,
327
+ })}
328
+ ```
329
+
330
+ You can retrieve the Markdown as string:
331
+
332
+ ```tsx
333
+ {myMarkdownContent.value}
334
+ {String(myMarkdownContent)}
335
+ {myMarkdownContent.toString()}
336
+ ```
337
+
338
+ And you can access your markdown metadata like :
339
+
340
+ ```tsx
341
+ {myMarkdownContent.metadata}
342
+ {myMarkdownContent.metadata.title}
204
343
  ```
205
344
 
206
345
  </Tab>
207
346
  <Tab label="Solid" value="solid">
208
- Solid supports Markdown nodes directly in the JSX.
347
+ Solid supports Markdown nodes directly in JSX.
209
348
 
210
349
  ```tsx fileName="App.tsx"
211
350
  import { useIntlayer } from "solid-intlayer";
351
+ import { MarkdownProvider } from "solid-intlayer/markdown";
212
352
 
213
353
  const AppContent = () => {
214
354
  const { myMarkdownContent } = useIntlayer("app");
215
355
  return <div>{myMarkdownContent}</div>;
216
356
  };
357
+
358
+ const App = () => (
359
+ <MarkdownProvider
360
+ components={{
361
+ h1: (props) => <h1 style={{ color: "red" }}>{props.children}</h1>,
362
+ MyButton: (props) => <button {...props} />, // MDX component
363
+ }}
364
+ >
365
+ <AppContent />
366
+ </MarkdownProvider>
367
+ );
368
+ ```
369
+
370
+ > If `MarkdownProvider` not present, intlayer will render the markdown using the default Markdown to JSX parser.
371
+
372
+ You can also provide local overrides for specific nodes using the `.use()` method:
373
+
374
+ ```tsx
375
+ {myMarkdownContent.use({
376
+ h1: (props) => <h1 style={{ color: "red" }}>{props.children}</h1>,
377
+ })}
378
+ ```
379
+
380
+ You can retrieve the Markdown as string:
381
+
382
+ ```tsx
383
+ {myMarkdownContent.value}
384
+ {String(myMarkdownContent)}
385
+ {myMarkdownContent.toString()}
386
+ ```
387
+
388
+ And you can access your markdown metadata like :
389
+
390
+ ```tsx
391
+ {myMarkdownContent.metadata}
392
+ {myMarkdownContent.metadata.title}
217
393
  ```
218
394
 
219
395
  </Tab>
@@ -233,6 +409,8 @@ When you access content via `useIntlayer`, Markdown nodes are already prepared f
233
409
  }
234
410
  ```
235
411
 
412
+ > If the IntlayerMarkdown provider is not configured, Intlayer will render using the default compiler.
413
+
236
414
  You can also provide local overrides for specific nodes using the `.use()` method:
237
415
 
238
416
  ```typescript
@@ -241,12 +419,27 @@ When you access content via `useIntlayer`, Markdown nodes are already prepared f
241
419
  })
242
420
  ```
243
421
 
422
+ You can retrieve the Markdown as string:
423
+
424
+ ```typescript
425
+ content().myMarkdownContent.value
426
+ String(content().myMarkdownContent)
427
+ content().myMarkdownContent.toString()
428
+ ```
429
+
430
+ And you can access your markdown metadata like :
431
+
432
+ ```typescript
433
+ content().myMarkdownContent.metadata
434
+ content().myMarkdownContent.metadata.title
435
+ ```
436
+
244
437
  </Tab>
245
438
  </Tabs>
246
439
 
247
- ### 2. Manual Rendering & Advanced Tools
440
+ ### 2. Helper Utilities (Markdown Strings Only)
248
441
 
249
- If you need to render raw Markdown strings or have more control over the rendering process, use the following tools.
442
+ These utilities render **raw Markdown strings** and are independent of `useIntlayer`. Use them when you need to render Markdown from sources other than your dictionaries.
250
443
 
251
444
  <Tabs group="framework">
252
445
  <Tab label="React / Next.js" value="react">
@@ -420,7 +613,7 @@ If you need to render raw Markdown strings or have more control over the renderi
420
613
 
421
614
  ## Global Configuration with `MarkdownProvider`
422
615
 
423
- You can configure Markdown rendering globally for your entire application. This avoids passing the same props to every renderer.
616
+ `MarkdownProvider` (or its framework equivalent) configures the Markdown rendering pipeline for your entire application. It applies to both the automatic `useIntlayer` rendering and the helper utilities. Options set here are the defaults — `.use()` overrides them at the node level.
424
617
 
425
618
  <Tabs group="framework">
426
619
  <Tab label="React / Next.js" value="react">
@@ -431,8 +624,9 @@ You can configure Markdown rendering globally for your entire application. This
431
624
  export const AppProvider = ({ children }) => (
432
625
  <MarkdownProvider
433
626
  components={{
434
- h1: ({ children }) => <h1 className="text-2xl font-bold">{children}</h1>,
435
- a: ({ href, children }) => <Link to={href}>{children}</Link>,
627
+ h1: (props) => <h1 style={{color: 'green'}} {...props} />,
628
+ a: ({ href, ...props }) => <a style={{color: 'red'}} {...props} />,
629
+ MyCustomJSXComponent: (props) => <span style={{color: 'red'}} {...props} />,
436
630
  }}
437
631
  >
438
632
  {children}
@@ -440,6 +634,8 @@ You can configure Markdown rendering globally for your entire application. This
440
634
  );
441
635
  ```
442
636
 
637
+ > MDX is supported — any component name used inside your Markdown (e.g. `<MyCustomJSXComponent />`) is resolved against the `components` map.
638
+
443
639
  You can also use your own markdown renderer:
444
640
 
445
641
  ```tsx fileName="AppProvider.tsx"
@@ -448,8 +644,8 @@ You can configure Markdown rendering globally for your entire application. This
448
644
  export const AppProvider = ({ children }) => (
449
645
  <MarkdownProvider
450
646
  renderMarkdown={async (md) => {
451
- const { compileMarkdown } = await import('react-intlayer/markdown');
452
- return compileMarkdown(md);
647
+ const { renderMarkdown } = await import('react-intlayer/markdown');
648
+ return renderMarkdown(md);
453
649
  }}
454
650
  >
455
651
  {children}
@@ -497,8 +693,8 @@ You can configure Markdown rendering globally for your entire application. This
497
693
  app.use(intlayer);
498
694
  app.use(intlayerMarkdown, {
499
695
  renderMarkdown: async (md) => {
500
- const { compileMarkdown } = await import('vue-intlayer/markdown');
501
- return compileMarkdown(md);
696
+ const { renderMarkdown } = await import('vue-intlayer/markdown');
697
+ return renderMarkdown(md);
502
698
  },
503
699
  });
504
700
 
@@ -534,8 +730,8 @@ You can configure Markdown rendering globally for your entire application. This
534
730
 
535
731
  <MarkdownProvider
536
732
  renderMarkdown={async (md) => {
537
- const { compileMarkdown } = await import('svelte-intlayer/markdown');
538
- return compileMarkdown(md);
733
+ const { renderMarkdown } = await import('svelte-intlayer/markdown');
734
+ return renderMarkdown(md);
539
735
  }}
540
736
  >
541
737
  <slot />
@@ -569,8 +765,8 @@ You can configure Markdown rendering globally for your entire application. This
569
765
  export const AppProvider = ({ children }) => (
570
766
  <MarkdownProvider
571
767
  renderMarkdown={async (md) => {
572
- const { compileMarkdown } = await import('preact-intlayer/markdown');
573
- return compileMarkdown(md);
768
+ const { renderMarkdown } = await import('preact-intlayer/markdown');
769
+ return renderMarkdown(md);
574
770
  }}
575
771
  >
576
772
  {children}
@@ -605,8 +801,8 @@ You can configure Markdown rendering globally for your entire application. This
605
801
  export const AppProvider = (props) => (
606
802
  <MarkdownProvider
607
803
  renderMarkdown={async (md) => {
608
- const { compileMarkdown } = await import('solid-intlayer/markdown');
609
- return compileMarkdown(md);
804
+ const { renderMarkdown } = await import('solid-intlayer/markdown');
805
+ return renderMarkdown(md);
610
806
  }}
611
807
  >
612
808
  {props.children}
@@ -642,8 +838,8 @@ You can configure Markdown rendering globally for your entire application. This
642
838
  providers: [
643
839
  createIntlayerMarkdownProvider({
644
840
  renderMarkdown: async (md) => {
645
- const { compileMarkdown } = await import('angular-intlayer/markdown');
646
- return compileMarkdown(md);
841
+ const { renderMarkdown } = await import('angular-intlayer/markdown');
842
+ return renderMarkdown(md);
647
843
  },
648
844
  }),
649
845
  ],