@intlayer/docs 8.10.0-canary.0 → 8.10.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/docs/ar/dictionary/markdown.md +409 -88
- package/docs/de/dictionary/markdown.md +279 -107
- package/docs/en/dictionary/markdown.md +237 -37
- package/docs/en-GB/dictionary/markdown.md +361 -76
- package/docs/es/dictionary/markdown.md +295 -123
- package/docs/fr/dictionary/markdown.md +301 -129
- package/docs/hi/dictionary/markdown.md +376 -90
- package/docs/id/dictionary/markdown.md +377 -91
- package/docs/it/dictionary/markdown.md +296 -129
- package/docs/ko/dictionary/markdown.md +306 -134
- package/docs/pl/dictionary/markdown.md +287 -116
- package/docs/pt/dictionary/markdown.md +287 -116
- package/docs/ru/dictionary/markdown.md +78 -513
- package/docs/tr/dictionary/markdown.md +300 -130
- package/docs/uk/dictionary/markdown.md +386 -100
- package/docs/vi/dictionary/markdown.md +383 -97
- package/docs/zh/dictionary/markdown.md +293 -125
- package/package.json +7 -7
- package/docs/ja/dictionary/markdown.md +0 -666
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
createdAt: 2025-02-07
|
|
3
3
|
updatedAt: 2026-05-19
|
|
4
4
|
title: Markdown
|
|
5
|
-
description: Scopri come dichiarare e utilizzare contenuti Markdown nel tuo sito web multilingue con Intlayer. Segui i passaggi in questa documentazione online per integrare Markdown nel tuo progetto
|
|
5
|
+
description: Scopri come dichiarare e utilizzare i contenuti Markdown nel tuo sito web multilingue con Intlayer. Segui i passaggi in questa documentazione online per integrare perfettamente Markdown nel tuo progetto.
|
|
6
6
|
keywords:
|
|
7
7
|
- Markdown
|
|
8
8
|
- Internazionalizzazione
|
|
@@ -22,46 +22,46 @@ history:
|
|
|
22
22
|
changes: "Aggiunto il supporto per i file `.content.md`"
|
|
23
23
|
- version: 8.5.0
|
|
24
24
|
date: 2026-03-24
|
|
25
|
-
changes: "
|
|
25
|
+
changes: "Aggiunto l'oggetto plugin `intlayerMarkdown`; usa `app.use(intlayerMarkdown)` al posto di `app.use(installIntlayerMarkdown)`"
|
|
26
26
|
- version: 8.5.0
|
|
27
27
|
date: 2026-03-24
|
|
28
|
-
changes: "
|
|
28
|
+
changes: "Spostata l'importazione da `{{framework}}-intlayer` a `{{framework}}-intlayer/markdown`"
|
|
29
29
|
- version: 8.0.0
|
|
30
30
|
date: 2026-01-22
|
|
31
|
-
changes: "
|
|
31
|
+
changes: "Aggiunte le utility MarkdownRenderer / useMarkdownRenderer / renderMarkdown e l'opzione forceInline"
|
|
32
32
|
- version: 8.0.0
|
|
33
33
|
date: 2026-01-18
|
|
34
|
-
changes: "Decorazione automatica
|
|
34
|
+
changes: "Decorazione automatica dei contenuti markdown, supporto per MDX e SSR"
|
|
35
35
|
- version: 5.5.10
|
|
36
36
|
date: 2025-06-29
|
|
37
|
-
changes: "
|
|
37
|
+
changes: "Inizializzazione della cronologia"
|
|
38
38
|
---
|
|
39
39
|
|
|
40
|
-
# Markdown /
|
|
40
|
+
# Markdown / Contenuti Rich Text
|
|
41
41
|
|
|
42
|
-
Intlayer supporta contenuti rich text definiti utilizzando la sintassi Markdown. Questo ti
|
|
42
|
+
Intlayer supporta contenuti rich text definiti utilizzando la sintassi Markdown. Questo ti permette di scrivere e mantenere facilmente contenuti con formattazione ricca, come blog, articoli e molto altro.
|
|
43
43
|
|
|
44
|
-
## Dichiarare
|
|
44
|
+
## Dichiarare Contenuti Markdown
|
|
45
45
|
|
|
46
|
-
Puoi dichiarare contenuti Markdown usando la funzione `md` o semplicemente come stringa (se contiene sintassi Markdown).
|
|
46
|
+
Puoi dichiarare i contenuti Markdown usando la funzione `md` o semplicemente come stringa (se contiene la sintassi Markdown).
|
|
47
47
|
|
|
48
48
|
<Tabs>
|
|
49
49
|
<Tab label=".content.md" value=".content.md">
|
|
50
|
-
|
|
50
|
+
Dalla versione `8.10.0`, puoi dichiarare i contenuti Markdown direttamente nei file `.content.md`. Intlayer rileverà e analizzerà automaticamente il contenuto Markdown.
|
|
51
51
|
|
|
52
|
-
```md fileName="markdown-file.
|
|
52
|
+
```md fileName="markdown-file.en.content.md"
|
|
53
53
|
---
|
|
54
54
|
key: my-markdown-content
|
|
55
55
|
description: Il mio contenuto
|
|
56
|
-
locale:
|
|
56
|
+
locale: en
|
|
57
57
|
---
|
|
58
58
|
|
|
59
59
|
# Il mio contenuto
|
|
60
60
|
|
|
61
|
-
Ecco un esempio di contenuto
|
|
61
|
+
Ecco un esempio di contenuto markdown
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
Il campo
|
|
64
|
+
Il campo front-matter `locale` è il campo che definisce la lingua del contenuto. È facoltativo. Se non viene fornito, Intlayer utilizzerà la lingua predefinita, che viene anche utilizzata come lingua di fallback se non è disponibile alcuna traduzione per una lingua specifica.
|
|
65
65
|
|
|
66
66
|
Esempio di struttura dei file:
|
|
67
67
|
|
|
@@ -75,11 +75,11 @@ Puoi dichiarare contenuti Markdown usando la funzione `md` o semplicemente come
|
|
|
75
75
|
└── markdown-file.es.content.md
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
Puoi aggiungere nel front-matter qualsiasi proprietà definita nella [
|
|
78
|
+
Puoi aggiungere nel front-matter qualsiasi proprietà definita nella [Definizione del Dizionario](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/dictionary/content_file.md)
|
|
79
79
|
|
|
80
80
|
</Tab>
|
|
81
|
-
<Tab label="
|
|
82
|
-
Usa la funzione `md` per dichiarare esplicitamente contenuti Markdown. Questo è utile se vuoi assicurarti che una stringa
|
|
81
|
+
<Tab label="Wrapping Manuale" value="manual-wrapping">
|
|
82
|
+
Usa la funzione `md` per dichiarare esplicitamente i contenuti Markdown. Questo è utile se vuoi assicurarti che una stringa venga trattata come Markdown anche se non contiene una sintassi evidente.
|
|
83
83
|
|
|
84
84
|
```typescript fileName="markdownDictionary.content.ts"
|
|
85
85
|
import { md, type Dictionary } from "intlayer";
|
|
@@ -95,34 +95,34 @@ Puoi dichiarare contenuti Markdown usando la funzione `md` o semplicemente come
|
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
</Tab>
|
|
98
|
-
<Tab label="
|
|
99
|
-
|
|
98
|
+
<Tab label="File Esterni" value="external-files">
|
|
99
|
+
Importa direttamente i file `.md` usando la funzione `file`.
|
|
100
100
|
|
|
101
101
|
```typescript fileName="markdownDictionary.content.ts"
|
|
102
|
+
import { md, file, t } from "intlayer";
|
|
103
|
+
|
|
102
104
|
export default {
|
|
103
105
|
key: "app",
|
|
104
|
-
contentAutoTransformation: true, // Abilita il rilevamento automatico del contenuto Markdown - Può essere impostato globalmente in intlayer.config.ts
|
|
105
106
|
content: {
|
|
106
|
-
|
|
107
|
+
content: t({
|
|
108
|
+
en: md(file("./myMarkdown.en.md")),
|
|
109
|
+
it: md(file("./myMarkdown.it.md")),
|
|
110
|
+
}),
|
|
107
111
|
},
|
|
108
112
|
};
|
|
109
113
|
```
|
|
110
114
|
|
|
111
115
|
</Tab>
|
|
112
|
-
<Tab label="File esterni" value="external-files">
|
|
113
|
-
Importa file `.md` direttamente usando la funzione `file`.
|
|
114
116
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
<Tab label="Rilevamento Automatico" value="automatic-detection">
|
|
118
|
+
Se la stringa contiene indicatori comuni di Markdown (come intestazioni, elenchi, link, ecc.), Intlayer la trasformerà automaticamente.
|
|
117
119
|
|
|
120
|
+
```typescript fileName="markdownDictionary.content.ts"
|
|
118
121
|
export default {
|
|
119
122
|
key: "app",
|
|
123
|
+
contentAutoTransformation: true, // Abilita il rilevamento automatico dei contenuti Markdown - Può essere impostato globalmente in intlayer.config.ts
|
|
120
124
|
content: {
|
|
121
|
-
|
|
122
|
-
en: md(file("./myMarkdown.en.md")),
|
|
123
|
-
fr: md(file("./myMarkdown.fr.md")),
|
|
124
|
-
it: md(file("./myMarkdown.it.md")),
|
|
125
|
-
}),
|
|
125
|
+
myMarkdownContent: "## Il mio titolo \n\nLorem Ipsum",
|
|
126
126
|
},
|
|
127
127
|
};
|
|
128
128
|
```
|
|
@@ -132,13 +132,19 @@ Puoi dichiarare contenuti Markdown usando la funzione `md` o semplicemente come
|
|
|
132
132
|
|
|
133
133
|
---
|
|
134
134
|
|
|
135
|
-
## Rendering
|
|
135
|
+
## Rendering del Markdown
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
Intlayer fornisce due modi indipendenti per eseguire il rendering del Markdown:
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
1. **Tramite `useIntlayer`**
|
|
140
|
+
— Intlayer trasforma automaticamente il nodo `md` nell'output nativo del framework (JSX, VNode, stringa HTML).
|
|
141
|
+
- Il Frontmatter viene analizzato ed esposto come `.metadata`. Puoi sovrascrivere il rendering su due livelli — globalmente con `MarkdownProvider` (o l'equivalente nel framework) e localmente per nodo con `.use()`. Entrambi possono essere combinati; `.use()` ha priorità su `MarkdownProvider`, il quale ha priorità su quello predefinito.
|
|
140
142
|
|
|
141
|
-
|
|
143
|
+
2. **Utility di supporto** — `<MarkdownRenderer />`, `useMarkdownRenderer()`, e `renderMarkdown()` sono strumenti indipendenti che accettano **solo stringhe Markdown pure**. Sono indipendenti da `useIntlayer` e non funzionano con i nodi decorati che esso restituisce.
|
|
144
|
+
|
|
145
|
+
Il rendering del Markdown supporta **MDX** — usa qualsiasi componente JSX/framework tramite nome direttamente nel tuo Markdown.
|
|
146
|
+
|
|
147
|
+
### 1. Rendering Automatico (tramite `useIntlayer`)
|
|
142
148
|
|
|
143
149
|
<Tabs group="framework">
|
|
144
150
|
<Tab label="React / Next.js" value="react">
|
|
@@ -146,24 +152,54 @@ Quando accedi al contenuto tramite `useIntlayer`, i nodi Markdown sono già pron
|
|
|
146
152
|
|
|
147
153
|
```tsx fileName="App.tsx"
|
|
148
154
|
import { useIntlayer } from "react-intlayer";
|
|
155
|
+
import { MarkdownProvider } from "react-intlayer/markdown";
|
|
149
156
|
|
|
150
157
|
const AppContent = () => {
|
|
151
158
|
const { myMarkdownContent } = useIntlayer("app");
|
|
159
|
+
|
|
152
160
|
return <div>{myMarkdownContent}</div>;
|
|
153
161
|
};
|
|
162
|
+
|
|
163
|
+
const App = () => (
|
|
164
|
+
<MarkdownProvider
|
|
165
|
+
components={{
|
|
166
|
+
h1: ({ children }) => <h1 style={{ color: "red" }}>{children}</h1>,
|
|
167
|
+
MyButton: (props) => <button {...props} />, // Componente MDX
|
|
168
|
+
}}
|
|
169
|
+
>
|
|
170
|
+
<AppContent />
|
|
171
|
+
</MarkdownProvider>
|
|
172
|
+
);
|
|
154
173
|
```
|
|
155
174
|
|
|
175
|
+
> Se `MarkdownProvider` non è presente, Intlayer eseguirà il rendering del markdown usando il parser da Markdown a JSX predefinito.
|
|
176
|
+
|
|
156
177
|
Puoi anche fornire sovrascritture locali per nodi specifici utilizzando il metodo `.use()`:
|
|
157
178
|
|
|
158
179
|
```tsx
|
|
159
180
|
{myMarkdownContent.use({
|
|
160
|
-
h1: ({ children }) => <h1
|
|
181
|
+
h1: ({ children }) => <h1 style={{ color: "red" }}>{children}</h1>,
|
|
161
182
|
})}
|
|
162
183
|
```
|
|
163
184
|
|
|
185
|
+
Puoi recuperare il Markdown come stringa:
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
{myMarkdownContent.value}
|
|
189
|
+
{String(myMarkdownContent)}
|
|
190
|
+
{myMarkdownContent.toString()}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
E puoi accedere ai metadati del tuo markdown in questo modo:
|
|
194
|
+
|
|
195
|
+
```tsx
|
|
196
|
+
{myMarkdownContent.metadata}
|
|
197
|
+
{myMarkdownContent.metadata.title}
|
|
198
|
+
```
|
|
199
|
+
|
|
164
200
|
</Tab>
|
|
165
201
|
<Tab label="Vue" value="vue">
|
|
166
|
-
In Vue, il contenuto Markdown può essere renderizzato
|
|
202
|
+
In Vue, il contenuto Markdown può essere renderizzato usando il tag `component` integrato o direttamente come nodo.
|
|
167
203
|
|
|
168
204
|
```vue fileName="App.vue"
|
|
169
205
|
<script setup>
|
|
@@ -176,48 +212,188 @@ Quando accedi al contenuto tramite `useIntlayer`, i nodi Markdown sono già pron
|
|
|
176
212
|
</template>
|
|
177
213
|
```
|
|
178
214
|
|
|
215
|
+
Configura globalmente tramite il plugin `intlayerMarkdown` (supporta componenti MDX personalizzati):
|
|
216
|
+
|
|
217
|
+
```ts fileName="main.ts"
|
|
218
|
+
import { intlayerMarkdown } from "vue-intlayer/markdown";
|
|
219
|
+
|
|
220
|
+
app.use(intlayerMarkdown, {
|
|
221
|
+
components: {
|
|
222
|
+
h1: (props) => h('h1', { style: { color: 'green' } }, props.children),
|
|
223
|
+
MyButton: (props) => h('button', props), // Componente MDX
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
> Se il plugin `intlayerMarkdown` non è installato, Intlayer eseguirà il rendering utilizzando il compilatore predefinito.
|
|
229
|
+
|
|
230
|
+
Puoi anche fornire sovrascritture locali per nodi specifici utilizzando il metodo `.use()`:
|
|
231
|
+
|
|
232
|
+
```vue
|
|
233
|
+
<component :is="myMarkdownContent.use({
|
|
234
|
+
h1: (props) => h('h1', { style: { color: 'red' } }, props.children),
|
|
235
|
+
})" />
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Puoi recuperare il Markdown come stringa:
|
|
239
|
+
|
|
240
|
+
```vue
|
|
241
|
+
{{ myMarkdownContent.value }}
|
|
242
|
+
{{ String(myMarkdownContent) }}
|
|
243
|
+
{{ myMarkdownContent.toString() }}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
E puoi accedere ai metadati del tuo markdown in questo modo:
|
|
247
|
+
|
|
248
|
+
```vue
|
|
249
|
+
<component :is="myMarkdownContent.metadata" />
|
|
250
|
+
<component :is="myMarkdownContent.metadata.title" />
|
|
251
|
+
```
|
|
252
|
+
|
|
179
253
|
</Tab>
|
|
180
254
|
<Tab label="Svelte" value="svelte">
|
|
181
|
-
Svelte renderizza Markdown come una stringa HTML per impostazione predefinita. Usa `{@html}` per renderizzarlo.
|
|
255
|
+
Svelte renderizza il Markdown come una stringa HTML per impostazione predefinita. Usa `{@html}` per renderizzarlo.
|
|
182
256
|
|
|
183
|
-
```svelte
|
|
257
|
+
```svelte fileName="App.svelte"
|
|
184
258
|
<script lang="ts">
|
|
185
259
|
import { useIntlayer } from "svelte-intlayer";
|
|
260
|
+
import { MarkdownProvider } from "svelte-intlayer/markdown";
|
|
261
|
+
import MyHeading from "./MyHeading.svelte";
|
|
262
|
+
|
|
186
263
|
const content = useIntlayer("app");
|
|
187
264
|
</script>
|
|
188
265
|
|
|
189
|
-
{
|
|
266
|
+
<MarkdownProvider components={{ h1: MyHeading }}>
|
|
267
|
+
{@html $content.myMarkdownContent}
|
|
268
|
+
</MarkdownProvider>
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
> Se `MarkdownProvider` non è presente, Intlayer renderizzerà il markdown usando il compilatore predefinito.
|
|
272
|
+
|
|
273
|
+
Puoi anche fornire sovrascritture locali per nodi specifici utilizzando il metodo `.use()`:
|
|
274
|
+
|
|
275
|
+
```svelte
|
|
276
|
+
{@html $content.myMarkdownContent.use({ ... })}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Puoi recuperare il Markdown come stringa:
|
|
280
|
+
|
|
281
|
+
```svelte
|
|
282
|
+
{$content.myMarkdownContent.value}
|
|
283
|
+
{String($content.myMarkdownContent)}
|
|
284
|
+
{$content.myMarkdownContent.toString()}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
E puoi accedere ai metadati del tuo markdown in questo modo:
|
|
288
|
+
|
|
289
|
+
```svelte
|
|
290
|
+
{$content.myMarkdownContent.metadata}
|
|
291
|
+
{$content.myMarkdownContent.metadata.title}
|
|
190
292
|
```
|
|
191
293
|
|
|
192
294
|
</Tab>
|
|
193
295
|
<Tab label="Preact" value="preact">
|
|
194
|
-
Preact supporta i nodi Markdown direttamente
|
|
296
|
+
Preact supporta i nodi Markdown direttamente in JSX.
|
|
195
297
|
|
|
196
298
|
```tsx fileName="App.tsx"
|
|
197
299
|
import { useIntlayer } from "preact-intlayer";
|
|
300
|
+
import { MarkdownProvider } from "preact-intlayer/markdown";
|
|
198
301
|
|
|
199
302
|
const AppContent = () => {
|
|
200
303
|
const { myMarkdownContent } = useIntlayer("app");
|
|
201
304
|
return <div>{myMarkdownContent}</div>;
|
|
202
305
|
};
|
|
306
|
+
|
|
307
|
+
const App = () => (
|
|
308
|
+
<MarkdownProvider
|
|
309
|
+
components={{
|
|
310
|
+
h1: ({ children }) => <h1 style={{ color: "red" }}>{children}</h1>,
|
|
311
|
+
MyButton: (props) => <button {...props} />, // Componente MDX
|
|
312
|
+
}}
|
|
313
|
+
>
|
|
314
|
+
<AppContent />
|
|
315
|
+
</MarkdownProvider>
|
|
316
|
+
);
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
> Se `MarkdownProvider` non è presente, Intlayer eseguirà il rendering del markdown usando il parser da Markdown a JSX predefinito.
|
|
320
|
+
|
|
321
|
+
Puoi anche fornire sovrascritture locali per nodi specifici utilizzando il metodo `.use()`:
|
|
322
|
+
|
|
323
|
+
```tsx
|
|
324
|
+
{myMarkdownContent.use({
|
|
325
|
+
h1: ({ children }) => <h1 style={{ color: "red" }}>{children}</h1>,
|
|
326
|
+
})}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
Puoi recuperare il Markdown come stringa:
|
|
330
|
+
|
|
331
|
+
```tsx
|
|
332
|
+
{myMarkdownContent.value}
|
|
333
|
+
{String(myMarkdownContent)}
|
|
334
|
+
{myMarkdownContent.toString()}
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
E puoi accedere ai metadati del tuo markdown in questo modo:
|
|
338
|
+
|
|
339
|
+
```tsx
|
|
340
|
+
{myMarkdownContent.metadata}
|
|
341
|
+
{myMarkdownContent.metadata.title}
|
|
203
342
|
```
|
|
204
343
|
|
|
205
344
|
</Tab>
|
|
206
345
|
<Tab label="Solid" value="solid">
|
|
207
|
-
Solid supporta i nodi Markdown direttamente
|
|
346
|
+
Solid supporta i nodi Markdown direttamente in JSX.
|
|
208
347
|
|
|
209
348
|
```tsx fileName="App.tsx"
|
|
210
349
|
import { useIntlayer } from "solid-intlayer";
|
|
350
|
+
import { MarkdownProvider } from "solid-intlayer/markdown";
|
|
211
351
|
|
|
212
352
|
const AppContent = () => {
|
|
213
353
|
const { myMarkdownContent } = useIntlayer("app");
|
|
214
354
|
return <div>{myMarkdownContent}</div>;
|
|
215
355
|
};
|
|
356
|
+
|
|
357
|
+
const App = () => (
|
|
358
|
+
<MarkdownProvider
|
|
359
|
+
components={{
|
|
360
|
+
h1: (props) => <h1 style={{ color: "red" }}>{props.children}</h1>,
|
|
361
|
+
MyButton: (props) => <button {...props} />, // Componente MDX
|
|
362
|
+
}}
|
|
363
|
+
>
|
|
364
|
+
<AppContent />
|
|
365
|
+
</MarkdownProvider>
|
|
366
|
+
);
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
> Se `MarkdownProvider` non è presente, Intlayer eseguirà il rendering del markdown usando il parser da Markdown a JSX predefinito.
|
|
370
|
+
|
|
371
|
+
Puoi anche fornire sovrascritture locali per nodi specifici utilizzando il metodo `.use()`:
|
|
372
|
+
|
|
373
|
+
```tsx
|
|
374
|
+
{myMarkdownContent.use({
|
|
375
|
+
h1: (props) => <h1 style={{ color: "red" }}>{props.children}</h1>,
|
|
376
|
+
})}
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
Puoi recuperare il Markdown come stringa:
|
|
380
|
+
|
|
381
|
+
```tsx
|
|
382
|
+
{myMarkdownContent.value}
|
|
383
|
+
{String(myMarkdownContent)}
|
|
384
|
+
{myMarkdownContent.toString()}
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
E puoi accedere ai metadati del tuo markdown in questo modo:
|
|
388
|
+
|
|
389
|
+
```tsx
|
|
390
|
+
{myMarkdownContent.metadata}
|
|
391
|
+
{myMarkdownContent.metadata.title}
|
|
216
392
|
```
|
|
217
393
|
|
|
218
394
|
</Tab>
|
|
219
395
|
<Tab label="Angular" value="angular">
|
|
220
|
-
Angular utilizza la direttiva `[innerHTML]` per
|
|
396
|
+
Angular utilizza la direttiva `[innerHTML]` per eseguire il rendering del contenuto Markdown.
|
|
221
397
|
|
|
222
398
|
```typescript fileName="app.component.ts"
|
|
223
399
|
import { Component } from "@angular/core";
|
|
@@ -232,6 +408,8 @@ Quando accedi al contenuto tramite `useIntlayer`, i nodi Markdown sono già pron
|
|
|
232
408
|
}
|
|
233
409
|
```
|
|
234
410
|
|
|
411
|
+
> Se il provider IntlayerMarkdown non è configurato, Intlayer eseguirà il rendering utilizzando il compilatore predefinito.
|
|
412
|
+
|
|
235
413
|
Puoi anche fornire sovrascritture locali per nodi specifici utilizzando il metodo `.use()`:
|
|
236
414
|
|
|
237
415
|
```typescript
|
|
@@ -240,25 +418,40 @@ Quando accedi al contenuto tramite `useIntlayer`, i nodi Markdown sono già pron
|
|
|
240
418
|
})
|
|
241
419
|
```
|
|
242
420
|
|
|
421
|
+
Puoi recuperare il Markdown come stringa:
|
|
422
|
+
|
|
423
|
+
```typescript
|
|
424
|
+
content().myMarkdownContent.value
|
|
425
|
+
String(content().myMarkdownContent)
|
|
426
|
+
content().myMarkdownContent.toString()
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
E puoi accedere ai metadati del tuo markdown in questo modo:
|
|
430
|
+
|
|
431
|
+
```typescript
|
|
432
|
+
content().myMarkdownContent.metadata
|
|
433
|
+
content().myMarkdownContent.metadata.title
|
|
434
|
+
```
|
|
435
|
+
|
|
243
436
|
</Tab>
|
|
244
437
|
</Tabs>
|
|
245
438
|
|
|
246
|
-
### 2.
|
|
439
|
+
### 2. Utility di Supporto (Solo Stringhe Markdown)
|
|
247
440
|
|
|
248
|
-
|
|
441
|
+
Queste utility eseguono il rendering **solo di stringhe Markdown pure** e sono indipendenti da `useIntlayer`. Usale quando hai bisogno di renderizzare Markdown da fonti diverse dai tuoi dizionari.
|
|
249
442
|
|
|
250
443
|
<Tabs group="framework">
|
|
251
444
|
<Tab label="React / Next.js" value="react">
|
|
252
445
|
|
|
253
446
|
#### Componente `<MarkdownRenderer />`
|
|
254
447
|
|
|
255
|
-
|
|
448
|
+
Esegue il rendering di una stringa Markdown con opzioni specifiche.
|
|
256
449
|
|
|
257
450
|
```tsx
|
|
258
451
|
import { MarkdownRenderer } from "react-intlayer/markdown";
|
|
259
452
|
|
|
260
453
|
<MarkdownRenderer forceBlock={true} tagfilter={true}>
|
|
261
|
-
{"# Il
|
|
454
|
+
{"# Il Mio Titolo"}
|
|
262
455
|
</MarkdownRenderer>
|
|
263
456
|
```
|
|
264
457
|
|
|
@@ -274,16 +467,16 @@ Se hai bisogno di renderizzare stringhe Markdown grezze o di avere un maggiore c
|
|
|
274
467
|
components: { h1: (props) => <h1 {...props} className="custom" /> }
|
|
275
468
|
});
|
|
276
469
|
|
|
277
|
-
return renderMarkdown("# Il
|
|
470
|
+
return renderMarkdown("# Il Mio Titolo");
|
|
278
471
|
```
|
|
279
472
|
|
|
280
473
|
#### Utility `renderMarkdown()`
|
|
281
|
-
Utility
|
|
474
|
+
Utility indipendente per il rendering al di fuori dei componenti.
|
|
282
475
|
|
|
283
476
|
```tsx
|
|
284
477
|
import { renderMarkdown } from "react-intlayer/markdown";
|
|
285
478
|
|
|
286
|
-
const jsx = renderMarkdown("# Il
|
|
479
|
+
const jsx = renderMarkdown("# Il Mio Titolo", { forceBlock: true });
|
|
287
480
|
```
|
|
288
481
|
|
|
289
482
|
</Tab>
|
|
@@ -297,7 +490,7 @@ Se hai bisogno di renderizzare stringhe Markdown grezze o di avere un maggiore c
|
|
|
297
490
|
</script>
|
|
298
491
|
|
|
299
492
|
<template>
|
|
300
|
-
<MarkdownRenderer :forceBlock="true" content="# Il
|
|
493
|
+
<MarkdownRenderer :forceBlock="true" content="# Il Mio Titolo" />
|
|
301
494
|
</template>
|
|
302
495
|
```
|
|
303
496
|
|
|
@@ -311,7 +504,7 @@ Se hai bisogno di renderizzare stringhe Markdown grezze o di avere un maggiore c
|
|
|
311
504
|
import { MarkdownRenderer } from "svelte-intlayer/markdown";
|
|
312
505
|
</script>
|
|
313
506
|
|
|
314
|
-
<MarkdownRenderer forceBlock={true} value="# Il
|
|
507
|
+
<MarkdownRenderer forceBlock={true} value="# Il Mio Titolo" />
|
|
315
508
|
```
|
|
316
509
|
|
|
317
510
|
#### Hook `useMarkdownRenderer()`
|
|
@@ -322,7 +515,7 @@ Se hai bisogno di renderizzare stringhe Markdown grezze o di avere un maggiore c
|
|
|
322
515
|
const render = useMarkdownRenderer();
|
|
323
516
|
</script>
|
|
324
517
|
|
|
325
|
-
{@html render("# Il
|
|
518
|
+
{@html render("# Il Mio Titolo")}
|
|
326
519
|
```
|
|
327
520
|
|
|
328
521
|
#### Utility `renderMarkdown()`
|
|
@@ -332,7 +525,7 @@ Se hai bisogno di renderizzare stringhe Markdown grezze o di avere un maggiore c
|
|
|
332
525
|
import { renderMarkdown } from "svelte-intlayer/markdown";
|
|
333
526
|
</script>
|
|
334
527
|
|
|
335
|
-
{@html renderMarkdown("# Il
|
|
528
|
+
{@html renderMarkdown("# Il Mio Titolo")}
|
|
336
529
|
```
|
|
337
530
|
|
|
338
531
|
</Tab>
|
|
@@ -343,7 +536,7 @@ Se hai bisogno di renderizzare stringhe Markdown grezze o di avere un maggiore c
|
|
|
343
536
|
import { MarkdownRenderer } from "preact-intlayer/markdown";
|
|
344
537
|
|
|
345
538
|
<MarkdownRenderer forceBlock={true}>
|
|
346
|
-
{"# Il
|
|
539
|
+
{"# Il Mio Titolo"}
|
|
347
540
|
</MarkdownRenderer>
|
|
348
541
|
```
|
|
349
542
|
|
|
@@ -354,7 +547,7 @@ Se hai bisogno di renderizzare stringhe Markdown grezze o di avere un maggiore c
|
|
|
354
547
|
|
|
355
548
|
const render = useMarkdownRenderer();
|
|
356
549
|
|
|
357
|
-
return <div>{render("# Il
|
|
550
|
+
return <div>{render("# Il Mio Titolo")}</div>;
|
|
358
551
|
```
|
|
359
552
|
|
|
360
553
|
#### Utility `renderMarkdown()`
|
|
@@ -362,7 +555,7 @@ Se hai bisogno di renderizzare stringhe Markdown grezze o di avere un maggiore c
|
|
|
362
555
|
```tsx
|
|
363
556
|
import { renderMarkdown } from "preact-intlayer/markdown";
|
|
364
557
|
|
|
365
|
-
return <div>{renderMarkdown("# Il
|
|
558
|
+
return <div>{renderMarkdown("# Il Mio Titolo")}</div>;
|
|
366
559
|
```
|
|
367
560
|
|
|
368
561
|
</Tab>
|
|
@@ -373,7 +566,7 @@ Se hai bisogno di renderizzare stringhe Markdown grezze o di avere un maggiore c
|
|
|
373
566
|
import { MarkdownRenderer } from "solid-intlayer/markdown";
|
|
374
567
|
|
|
375
568
|
<MarkdownRenderer forceBlock={true}>
|
|
376
|
-
{"# Il
|
|
569
|
+
{"# Il Mio Titolo"}
|
|
377
570
|
</MarkdownRenderer>
|
|
378
571
|
```
|
|
379
572
|
|
|
@@ -384,7 +577,7 @@ Se hai bisogno di renderizzare stringhe Markdown grezze o di avere un maggiore c
|
|
|
384
577
|
|
|
385
578
|
const render = useMarkdownRenderer();
|
|
386
579
|
|
|
387
|
-
return <div>{render("# Il
|
|
580
|
+
return <div>{render("# Il Mio Titolo")}</div>;
|
|
388
581
|
```
|
|
389
582
|
|
|
390
583
|
#### Utility `renderMarkdown()`
|
|
@@ -392,13 +585,13 @@ Se hai bisogno di renderizzare stringhe Markdown grezze o di avere un maggiore c
|
|
|
392
585
|
```tsx
|
|
393
586
|
import { renderMarkdown } from "solid-intlayer/markdown";
|
|
394
587
|
|
|
395
|
-
return <div>{renderMarkdown("# Il
|
|
588
|
+
return <div>{renderMarkdown("# Il Mio Titolo")}</div>;
|
|
396
589
|
```
|
|
397
590
|
|
|
398
591
|
</Tab>
|
|
399
592
|
<Tab label="Angular" value="angular">
|
|
400
593
|
#### Servizio `IntlayerMarkdownService`
|
|
401
|
-
|
|
594
|
+
Esegue il rendering di una stringa Markdown utilizzando il servizio.
|
|
402
595
|
|
|
403
596
|
```typescript
|
|
404
597
|
import { IntlayerMarkdownService } from "angular-intlayer/markdown";
|
|
@@ -417,9 +610,9 @@ Se hai bisogno di renderizzare stringhe Markdown grezze o di avere un maggiore c
|
|
|
417
610
|
|
|
418
611
|
---
|
|
419
612
|
|
|
420
|
-
## Configurazione
|
|
613
|
+
## Configurazione Globale con `MarkdownProvider`
|
|
421
614
|
|
|
422
|
-
|
|
615
|
+
Il `MarkdownProvider` (o il suo equivalente nel framework) configura la pipeline di rendering Markdown per l'intera applicazione. Questo si applica sia al rendering automatico di `useIntlayer` che alle utility di supporto. Le opzioni impostate qui sono quelle predefinite — `.use()` le sovrascrive a livello di nodo.
|
|
423
616
|
|
|
424
617
|
<Tabs group="framework">
|
|
425
618
|
<Tab label="React / Next.js" value="react">
|
|
@@ -430,8 +623,9 @@ Puoi configurare il rendering Markdown a livello globale per l'intera applicazio
|
|
|
430
623
|
export const AppProvider = ({ children }) => (
|
|
431
624
|
<MarkdownProvider
|
|
432
625
|
components={{
|
|
433
|
-
h1: (
|
|
434
|
-
a: ({ href,
|
|
626
|
+
h1: (props) => <h1 style={{color: 'green'}} {...props} />,
|
|
627
|
+
a: ({ href, ...props }) => <a style={{color: 'red'}} {...props} />,
|
|
628
|
+
MyCustomJSXComponent: (props) => <span style={{color: 'red'}} {...props} />,
|
|
435
629
|
}}
|
|
436
630
|
>
|
|
437
631
|
{children}
|
|
@@ -439,7 +633,9 @@ Puoi configurare il rendering Markdown a livello globale per l'intera applicazio
|
|
|
439
633
|
);
|
|
440
634
|
```
|
|
441
635
|
|
|
442
|
-
|
|
636
|
+
> MDX è supportato — qualsiasi nome di componente usato all'interno del tuo Markdown (es. `<MyCustomJSXComponent />`) viene risolto tramite la mappa `components`.
|
|
637
|
+
|
|
638
|
+
Puoi anche usare il tuo renderer markdown:
|
|
443
639
|
|
|
444
640
|
```tsx fileName="AppProvider.tsx"
|
|
445
641
|
import { MarkdownProvider } from "react-intlayer/markdown";
|
|
@@ -447,8 +643,9 @@ Puoi configurare il rendering Markdown a livello globale per l'intera applicazio
|
|
|
447
643
|
export const AppProvider = ({ children }) => (
|
|
448
644
|
<MarkdownProvider
|
|
449
645
|
renderMarkdown={async (md) => {
|
|
450
|
-
|
|
451
|
-
|
|
646
|
+
// Use dynamic import to reduce the bundle size of your application
|
|
647
|
+
const { renderMarkdown } = await import('react-intlayer/markdown');
|
|
648
|
+
return renderMarkdown(md);
|
|
452
649
|
}}
|
|
453
650
|
>
|
|
454
651
|
{children}
|
|
@@ -456,7 +653,7 @@ Puoi configurare il rendering Markdown a livello globale per l'intera applicazio
|
|
|
456
653
|
);
|
|
457
654
|
```
|
|
458
655
|
|
|
459
|
-
> Importare dinamicamente il tuo renderer Markdown è un
|
|
656
|
+
> Importare dinamicamente il tuo renderer Markdown è un buon modo per ridurre le dimensioni del bundle della tua applicazione.
|
|
460
657
|
|
|
461
658
|
</Tab>
|
|
462
659
|
<Tab label="Vue" value="vue">
|
|
@@ -483,7 +680,7 @@ Puoi configurare il rendering Markdown a livello globale per l'intera applicazio
|
|
|
483
680
|
app.mount("#app");
|
|
484
681
|
```
|
|
485
682
|
|
|
486
|
-
Puoi anche
|
|
683
|
+
Puoi anche usare il tuo renderer markdown:
|
|
487
684
|
|
|
488
685
|
```typescript fileName="main.ts"
|
|
489
686
|
import { createApp } from "vue";
|
|
@@ -496,15 +693,15 @@ Puoi configurare il rendering Markdown a livello globale per l'intera applicazio
|
|
|
496
693
|
app.use(intlayer);
|
|
497
694
|
app.use(intlayerMarkdown, {
|
|
498
695
|
renderMarkdown: async (md) => {
|
|
499
|
-
const {
|
|
500
|
-
return
|
|
696
|
+
const { renderMarkdown } = await import('vue-intlayer/markdown');
|
|
697
|
+
return renderMarkdown(md);
|
|
501
698
|
},
|
|
502
699
|
});
|
|
503
700
|
|
|
504
701
|
app.mount("#app");
|
|
505
702
|
```
|
|
506
703
|
|
|
507
|
-
> Importare dinamicamente il tuo renderer Markdown è un
|
|
704
|
+
> Importare dinamicamente il tuo renderer Markdown è un buon modo per ridurre le dimensioni del bundle della tua applicazione.
|
|
508
705
|
|
|
509
706
|
</Tab>
|
|
510
707
|
<Tab label="Svelte" value="svelte">
|
|
@@ -524,7 +721,7 @@ Puoi configurare il rendering Markdown a livello globale per l'intera applicazio
|
|
|
524
721
|
</MarkdownProvider>
|
|
525
722
|
```
|
|
526
723
|
|
|
527
|
-
Puoi anche
|
|
724
|
+
Puoi anche usare il tuo renderer markdown:
|
|
528
725
|
|
|
529
726
|
```svelte fileName="App.svelte"
|
|
530
727
|
<script lang="ts">
|
|
@@ -533,15 +730,15 @@ Puoi configurare il rendering Markdown a livello globale per l'intera applicazio
|
|
|
533
730
|
|
|
534
731
|
<MarkdownProvider
|
|
535
732
|
renderMarkdown={async (md) => {
|
|
536
|
-
const {
|
|
537
|
-
return
|
|
733
|
+
const { renderMarkdown } = await import('svelte-intlayer/markdown');
|
|
734
|
+
return renderMarkdown(md);
|
|
538
735
|
}}
|
|
539
736
|
>
|
|
540
737
|
<slot />
|
|
541
738
|
</MarkdownProvider>
|
|
542
739
|
```
|
|
543
740
|
|
|
544
|
-
> Importare dinamicamente il tuo renderer Markdown è un
|
|
741
|
+
> Importare dinamicamente il tuo renderer Markdown è un buon modo per ridurre le dimensioni del bundle della tua applicazione.
|
|
545
742
|
|
|
546
743
|
</Tab>
|
|
547
744
|
<Tab label="Preact" value="preact">
|
|
@@ -560,7 +757,7 @@ Puoi configurare il rendering Markdown a livello globale per l'intera applicazio
|
|
|
560
757
|
);
|
|
561
758
|
```
|
|
562
759
|
|
|
563
|
-
Puoi anche
|
|
760
|
+
Puoi anche usare il tuo renderer markdown:
|
|
564
761
|
|
|
565
762
|
```tsx fileName="AppProvider.tsx"
|
|
566
763
|
import { MarkdownProvider } from "preact-intlayer/markdown";
|
|
@@ -568,8 +765,8 @@ Puoi configurare il rendering Markdown a livello globale per l'intera applicazio
|
|
|
568
765
|
export const AppProvider = ({ children }) => (
|
|
569
766
|
<MarkdownProvider
|
|
570
767
|
renderMarkdown={async (md) => {
|
|
571
|
-
const {
|
|
572
|
-
return
|
|
768
|
+
const { renderMarkdown } = await import('preact-intlayer/markdown');
|
|
769
|
+
return renderMarkdown(md);
|
|
573
770
|
}}
|
|
574
771
|
>
|
|
575
772
|
{children}
|
|
@@ -577,7 +774,7 @@ Puoi configurare il rendering Markdown a livello globale per l'intera applicazio
|
|
|
577
774
|
);
|
|
578
775
|
```
|
|
579
776
|
|
|
580
|
-
> Importare dinamicamente il tuo renderer Markdown è un
|
|
777
|
+
> Importare dinamicamente il tuo renderer Markdown è un buon modo per ridurre le dimensioni del bundle della tua applicazione.
|
|
581
778
|
|
|
582
779
|
</Tab>
|
|
583
780
|
<Tab label="Solid" value="solid">
|
|
@@ -596,7 +793,7 @@ Puoi configurare il rendering Markdown a livello globale per l'intera applicazio
|
|
|
596
793
|
);
|
|
597
794
|
```
|
|
598
795
|
|
|
599
|
-
Puoi anche
|
|
796
|
+
Puoi anche usare il tuo renderer markdown:
|
|
600
797
|
|
|
601
798
|
```tsx fileName="AppProvider.tsx"
|
|
602
799
|
import { MarkdownProvider } from "solid-intlayer/markdown";
|
|
@@ -604,8 +801,8 @@ Puoi configurare il rendering Markdown a livello globale per l'intera applicazio
|
|
|
604
801
|
export const AppProvider = (props) => (
|
|
605
802
|
<MarkdownProvider
|
|
606
803
|
renderMarkdown={async (md) => {
|
|
607
|
-
const {
|
|
608
|
-
return
|
|
804
|
+
const { renderMarkdown } = await import('solid-intlayer/markdown');
|
|
805
|
+
return renderMarkdown(md);
|
|
609
806
|
}}
|
|
610
807
|
>
|
|
611
808
|
{props.children}
|
|
@@ -613,59 +810,29 @@ Puoi configurare il rendering Markdown a livello globale per l'intera applicazio
|
|
|
613
810
|
);
|
|
614
811
|
```
|
|
615
812
|
|
|
616
|
-
> Importare dinamicamente il tuo renderer Markdown è un
|
|
813
|
+
> Importare dinamicamente il tuo renderer Markdown è un buon modo per ridurre le dimensioni del bundle della tua applicazione.
|
|
617
814
|
|
|
618
815
|
</Tab>
|
|
619
816
|
<Tab label="Angular" value="angular">
|
|
620
817
|
|
|
621
|
-
```typescript fileName="app.
|
|
622
|
-
import {
|
|
623
|
-
|
|
624
|
-
export const appConfig: ApplicationConfig = {
|
|
625
|
-
providers: [
|
|
626
|
-
createIntlayerMarkdownProvider({
|
|
627
|
-
components: {
|
|
628
|
-
h1: { class: "text-2xl font-bold" },
|
|
629
|
-
},
|
|
630
|
-
}),
|
|
631
|
-
],
|
|
632
|
-
};
|
|
633
|
-
```
|
|
634
|
-
|
|
635
|
-
Puoi anche utilizzare il tuo motore di rendering Markdown:
|
|
818
|
+
```typescript fileName="app.module.ts"
|
|
819
|
+
import { NgModule } from '@angular/core';
|
|
820
|
+
import { IntlayerMarkdownModule } from 'angular-intlayer/markdown';
|
|
636
821
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
export const appConfig: ApplicationConfig = {
|
|
641
|
-
providers: [
|
|
642
|
-
createIntlayerMarkdownProvider({
|
|
822
|
+
@NgModule({
|
|
823
|
+
imports: [
|
|
824
|
+
IntlayerMarkdownModule.forRoot({
|
|
643
825
|
renderMarkdown: async (md) => {
|
|
644
|
-
const {
|
|
645
|
-
return
|
|
646
|
-
}
|
|
647
|
-
})
|
|
648
|
-
]
|
|
649
|
-
}
|
|
826
|
+
const { renderMarkdown } = await import('angular-intlayer/markdown');
|
|
827
|
+
return renderMarkdown(md);
|
|
828
|
+
}
|
|
829
|
+
})
|
|
830
|
+
]
|
|
831
|
+
})
|
|
832
|
+
export class AppModule {}
|
|
650
833
|
```
|
|
651
834
|
|
|
652
|
-
> Importare dinamicamente il tuo renderer Markdown è un
|
|
835
|
+
> Importare dinamicamente il tuo renderer Markdown è un buon modo per ridurre le dimensioni del bundle della tua applicazione.
|
|
653
836
|
|
|
654
837
|
</Tab>
|
|
655
838
|
</Tabs>
|
|
656
|
-
|
|
657
|
-
---
|
|
658
|
-
|
|
659
|
-
## Riferimento delle opzioni
|
|
660
|
-
|
|
661
|
-
Queste opzioni possono essere passate a `MarkdownProvider`, `MarkdownRenderer`, `useMarkdownRenderer`, e `renderMarkdown`.
|
|
662
|
-
|
|
663
|
-
| Opzione | Tipo | Predefinito | Descrizione |
|
|
664
|
-
| :-------------------- | :---------- | :---------- | :-------------------------------------------------------------------------------------------------------- |
|
|
665
|
-
| `forceBlock` | `boolean` | `false` | Forza il wrapping dell'output in un elemento a livello di blocco (es. `<div>`). |
|
|
666
|
-
| `forceInline` | `boolean` | `false` | Forza il wrapping dell'output in un elemento inline (es. `<span>`). |
|
|
667
|
-
| `tagfilter` | `boolean` | `true` | Abilita il Tag Filter di GitHub per una maggiore sicurezza rimuovendo i tag HTML pericolosi. |
|
|
668
|
-
| `preserveFrontmatter` | `boolean` | `false` | Se `true`, il frontmatter all'inizio della stringa Markdown non verrà rimosso. |
|
|
669
|
-
| `components` | `Overrides` | `{}` | Una mappa di tag HTML a componenti personalizzati (es. `{ h1: MyHeading }`). |
|
|
670
|
-
| `wrapper` | `Component` | `null` | Un componente personalizzato per avvolgere il Markdown renderizzato. |
|
|
671
|
-
| `renderMarkdown` | `Function` | `null` | Una funzione di rendering personalizzata per sostituire completamente il compilatore Markdown di default. |
|