@intlayer/docs 8.10.0-canary.1 → 8.10.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.
- package/docs/ar/dictionary/markdown.md +349 -19
- package/docs/ar/interest_of_intlayer.md +1 -1
- package/docs/bn/interest_of_intlayer.md +1 -1
- package/docs/cs/interest_of_intlayer.md +1 -1
- package/docs/de/dictionary/markdown.md +349 -19
- package/docs/de/interest_of_intlayer.md +1 -1
- package/docs/en/dictionary/markdown.md +338 -20
- package/docs/en/interest_of_intlayer.md +1 -1
- package/docs/en-GB/dictionary/markdown.md +349 -19
- package/docs/en-GB/interest_of_intlayer.md +1 -1
- package/docs/es/dictionary/markdown.md +349 -19
- package/docs/es/interest_of_intlayer.md +1 -1
- package/docs/fr/dictionary/markdown.md +349 -19
- package/docs/fr/interest_of_intlayer.md +1 -1
- package/docs/hi/dictionary/markdown.md +349 -19
- package/docs/hi/interest_of_intlayer.md +1 -1
- package/docs/id/dictionary/markdown.md +349 -19
- package/docs/id/interest_of_intlayer.md +1 -1
- package/docs/it/dictionary/markdown.md +349 -19
- package/docs/it/interest_of_intlayer.md +1 -1
- package/docs/ja/interest_of_intlayer.md +1 -1
- package/docs/ko/dictionary/markdown.md +349 -19
- package/docs/ko/interest_of_intlayer.md +1 -1
- package/docs/nl/interest_of_intlayer.md +1 -1
- package/docs/pl/dictionary/markdown.md +349 -19
- package/docs/pl/interest_of_intlayer.md +1 -1
- package/docs/pt/benchmark/solid.md +1 -1
- package/docs/pt/benchmark/svelte.md +1 -1
- package/docs/pt/dictionary/markdown.md +349 -19
- package/docs/pt/interest_of_intlayer.md +1 -1
- package/docs/ru/dictionary/markdown.md +458 -16
- package/docs/ru/interest_of_intlayer.md +1 -1
- package/docs/tr/dictionary/markdown.md +349 -19
- package/docs/tr/interest_of_intlayer.md +1 -1
- package/docs/uk/dictionary/markdown.md +349 -19
- package/docs/uk/interest_of_intlayer.md +1 -1
- package/docs/ur/interest_of_intlayer.md +1 -1
- package/docs/vi/dictionary/markdown.md +349 -19
- package/docs/vi/interest_of_intlayer.md +1 -1
- package/docs/zh/dictionary/markdown.md +349 -19
- package/docs/zh/interest_of_intlayer.md +1 -1
- package/docs/zh-TW/interest_of_intlayer.md +1 -1
- package/package.json +7 -7
|
@@ -47,6 +47,7 @@ You can declare Markdown content using the `md` function or simply as a string (
|
|
|
47
47
|
|
|
48
48
|
<Tabs>
|
|
49
49
|
<Tab label=".content.md" value=".content.md">
|
|
50
|
+
|
|
50
51
|
Since version `8.10.0`, you can declare Markdown content directly in `.content.md` files. Intlayer will
|
|
51
52
|
automatically detect and parse the Markdown content.
|
|
52
53
|
|
|
@@ -96,42 +97,42 @@ You can declare Markdown content using the `md` function or simply as a string (
|
|
|
96
97
|
```
|
|
97
98
|
|
|
98
99
|
</Tab>
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
|
|
101
|
+
<Tab label="External Files" value="external-files">
|
|
102
|
+
Import `.md` files directly using the `file` function.
|
|
101
103
|
|
|
102
104
|
```typescript fileName="markdownDictionary.content.ts"
|
|
105
|
+
import { md, file, t } from "intlayer";
|
|
106
|
+
|
|
103
107
|
export default {
|
|
104
108
|
key: "app",
|
|
105
|
-
contentAutoTransformation: true, // Enable automatic detection of Markdown content - Can be set globally in intlayer.config.ts
|
|
106
109
|
content: {
|
|
107
|
-
|
|
110
|
+
content: t({
|
|
111
|
+
en: md(file("./myMarkdown.en.md")),
|
|
112
|
+
fr: md(file("./myMarkdown.fr.md")),
|
|
113
|
+
}),
|
|
108
114
|
},
|
|
109
115
|
};
|
|
110
116
|
```
|
|
111
117
|
|
|
112
118
|
</Tab>
|
|
113
119
|
|
|
114
|
-
<Tab label="
|
|
115
|
-
|
|
120
|
+
<Tab label="Automatic Detection" value="automatic-detection">
|
|
121
|
+
If the string contains common Markdown indicators (like headers, lists, links, etc.), Intlayer will automatically transform it.
|
|
116
122
|
|
|
117
123
|
```typescript fileName="markdownDictionary.content.ts"
|
|
118
|
-
import { md, file, t } from "intlayer";
|
|
119
|
-
|
|
120
124
|
export default {
|
|
121
125
|
key: "app",
|
|
126
|
+
contentAutoTransformation: true, // Enable automatic detection of Markdown content - Can be set globally in intlayer.config.ts
|
|
122
127
|
content: {
|
|
123
|
-
|
|
124
|
-
en: md(file("./myMarkdown.en.md")),
|
|
125
|
-
fr: md(file("./myMarkdown.fr.md")),
|
|
126
|
-
}),
|
|
128
|
+
myMarkdownContent: "## My title \n\nLorem Ipsum",
|
|
127
129
|
},
|
|
128
130
|
};
|
|
129
131
|
```
|
|
130
132
|
|
|
131
133
|
</Tab>
|
|
132
|
-
</Tabs>
|
|
133
134
|
|
|
134
|
-
|
|
135
|
+
</Tabs>
|
|
135
136
|
|
|
136
137
|
## Rendering Markdown
|
|
137
138
|
|
|
@@ -148,7 +149,7 @@ Markdown rendering supports **MDX** — use any JSX/framework component by name
|
|
|
148
149
|
### 1. Automatic Rendering (via `useIntlayer`)
|
|
149
150
|
|
|
150
151
|
<Tabs group="framework">
|
|
151
|
-
<Tab label="React
|
|
152
|
+
<Tab label="React" value="react">
|
|
152
153
|
Markdown nodes can be rendered directly as JSX.
|
|
153
154
|
|
|
154
155
|
```tsx fileName="App.tsx"
|
|
@@ -198,6 +199,57 @@ Markdown rendering supports **MDX** — use any JSX/framework component by name
|
|
|
198
199
|
{myMarkdownContent.metadata.title}
|
|
199
200
|
```
|
|
200
201
|
|
|
202
|
+
</Tab>
|
|
203
|
+
<Tab label="Next.js" value="nextjs">
|
|
204
|
+
Markdown nodes can be rendered directly as JSX.
|
|
205
|
+
|
|
206
|
+
```tsx fileName="App.tsx"
|
|
207
|
+
import { useIntlayer } from "next-intlayer";
|
|
208
|
+
import { MarkdownProvider } from "next-intlayer/markdown";
|
|
209
|
+
|
|
210
|
+
const AppContent = () => {
|
|
211
|
+
const { myMarkdownContent } = useIntlayer("app");
|
|
212
|
+
|
|
213
|
+
return <div>{myMarkdownContent}</div>;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const App = () => (
|
|
217
|
+
<MarkdownProvider
|
|
218
|
+
components={{
|
|
219
|
+
h1: ({ children }) => <h1 style={{ color: "red" }}>{children}</h1>,
|
|
220
|
+
MyButton: (props) => <button {...props} />, // MDX component
|
|
221
|
+
}}
|
|
222
|
+
>
|
|
223
|
+
<AppContent />
|
|
224
|
+
</MarkdownProvider>
|
|
225
|
+
);
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
> If `MarkdownProvider` not present, intlayer will render the markdown using the default Markdown to JSX parser.
|
|
229
|
+
|
|
230
|
+
You can also provide local overrides for specific nodes using the `.use()` method:
|
|
231
|
+
|
|
232
|
+
```tsx
|
|
233
|
+
{myMarkdownContent.use({
|
|
234
|
+
h1: ({ children }) => <h1 style={{ color: "red" }}>{children}</h1>,
|
|
235
|
+
})}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
You can retrieve the Markdown as string:
|
|
239
|
+
|
|
240
|
+
```tsx
|
|
241
|
+
{myMarkdownContent.value}
|
|
242
|
+
{String(myMarkdownContent)}
|
|
243
|
+
{myMarkdownContent.toString()}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
And you can access your markdown metadata like :
|
|
247
|
+
|
|
248
|
+
```tsx
|
|
249
|
+
{myMarkdownContent.metadata}
|
|
250
|
+
{myMarkdownContent.metadata.title}
|
|
251
|
+
```
|
|
252
|
+
|
|
201
253
|
</Tab>
|
|
202
254
|
<Tab label="Vue" value="vue">
|
|
203
255
|
In Vue, Markdown content can be rendered using the `component` built-in or directly as a node.
|
|
@@ -442,7 +494,7 @@ Markdown rendering supports **MDX** — use any JSX/framework component by name
|
|
|
442
494
|
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.
|
|
443
495
|
|
|
444
496
|
<Tabs group="framework">
|
|
445
|
-
<Tab label="React
|
|
497
|
+
<Tab label="React" value="react">
|
|
446
498
|
|
|
447
499
|
#### `<MarkdownRenderer />` Component
|
|
448
500
|
|
|
@@ -480,6 +532,45 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
|
|
|
480
532
|
const jsx = renderMarkdown("# My Title", { forceBlock: true });
|
|
481
533
|
```
|
|
482
534
|
|
|
535
|
+
</Tab>
|
|
536
|
+
<Tab label="Next.js" value="nextjs">
|
|
537
|
+
|
|
538
|
+
#### `<MarkdownRenderer />` Component
|
|
539
|
+
|
|
540
|
+
Render a Markdown string with specific options.
|
|
541
|
+
|
|
542
|
+
```tsx
|
|
543
|
+
import { MarkdownRenderer } from "next-intlayer/markdown";
|
|
544
|
+
|
|
545
|
+
<MarkdownRenderer forceBlock={true} tagfilter={true}>
|
|
546
|
+
{"# My Title"}
|
|
547
|
+
</MarkdownRenderer>
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
#### `useMarkdownRenderer()` Hook
|
|
551
|
+
|
|
552
|
+
Get a pre-configured renderer function.
|
|
553
|
+
|
|
554
|
+
```tsx
|
|
555
|
+
import { useMarkdownRenderer } from "next-intlayer/markdown";
|
|
556
|
+
|
|
557
|
+
const renderMarkdown = useMarkdownRenderer({
|
|
558
|
+
forceBlock: true,
|
|
559
|
+
components: { h1: (props) => <h1 {...props} className="custom" /> }
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
return renderMarkdown("# My Title");
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
#### `renderMarkdown()` Utility
|
|
566
|
+
Standalone utility for rendering outside of components.
|
|
567
|
+
|
|
568
|
+
```tsx
|
|
569
|
+
import { renderMarkdown } from "next-intlayer/markdown";
|
|
570
|
+
|
|
571
|
+
const jsx = renderMarkdown("# My Title", { forceBlock: true });
|
|
572
|
+
```
|
|
573
|
+
|
|
483
574
|
</Tab>
|
|
484
575
|
<Tab label="Vue" value="vue">
|
|
485
576
|
|
|
@@ -609,14 +700,12 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
|
|
|
609
700
|
</Tab>
|
|
610
701
|
</Tabs>
|
|
611
702
|
|
|
612
|
-
---
|
|
613
|
-
|
|
614
703
|
## Global Configuration with `MarkdownProvider`
|
|
615
704
|
|
|
616
705
|
`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.
|
|
617
706
|
|
|
618
707
|
<Tabs group="framework">
|
|
619
|
-
<Tab label="React
|
|
708
|
+
<Tab label="React" value="react">
|
|
620
709
|
|
|
621
710
|
```tsx fileName="AppProvider.tsx"
|
|
622
711
|
import { MarkdownProvider } from "react-intlayer/markdown";
|
|
@@ -634,6 +723,7 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
|
|
|
634
723
|
);
|
|
635
724
|
```
|
|
636
725
|
|
|
726
|
+
|
|
637
727
|
> MDX is supported — any component name used inside your Markdown (e.g. `<MyCustomJSXComponent />`) is resolved against the `components` map.
|
|
638
728
|
|
|
639
729
|
You can also use your own markdown renderer:
|
|
@@ -644,6 +734,7 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
|
|
|
644
734
|
export const AppProvider = ({ children }) => (
|
|
645
735
|
<MarkdownProvider
|
|
646
736
|
renderMarkdown={async (md) => {
|
|
737
|
+
// Use dynamic import to reduce the bundle size of your application
|
|
647
738
|
const { renderMarkdown } = await import('react-intlayer/markdown');
|
|
648
739
|
return renderMarkdown(md);
|
|
649
740
|
}}
|
|
@@ -655,6 +746,48 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
|
|
|
655
746
|
|
|
656
747
|
> Importing your Markdown renderer dynamically is a good way to reduce the bundle size of your application.
|
|
657
748
|
|
|
749
|
+
</Tab>
|
|
750
|
+
<Tab label="Next.js" value="nextjs">
|
|
751
|
+
|
|
752
|
+
```tsx fileName="AppProvider.tsx"
|
|
753
|
+
import { MarkdownProvider } from "next-intlayer/markdown";
|
|
754
|
+
|
|
755
|
+
export const AppProvider = ({ children }) => (
|
|
756
|
+
<MarkdownProvider
|
|
757
|
+
components={{
|
|
758
|
+
h1: (props) => <h1 style={{color: 'green'}} {...props} />,
|
|
759
|
+
a: ({ href, ...props }) => <a style={{color: 'red'}} {...props} />,
|
|
760
|
+
MyCustomJSXComponent: (props) => <span style={{color: 'red'}} {...props} />,
|
|
761
|
+
}}
|
|
762
|
+
>
|
|
763
|
+
{children}
|
|
764
|
+
</MarkdownProvider>
|
|
765
|
+
);
|
|
766
|
+
```
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
> MDX is supported — any component name used inside your Markdown (e.g. `<MyCustomJSXComponent />`) is resolved against the `components` map.
|
|
770
|
+
|
|
771
|
+
You can also use your own markdown renderer:
|
|
772
|
+
|
|
773
|
+
```tsx fileName="AppProvider.tsx"
|
|
774
|
+
import { MarkdownProvider } from "next-intlayer/markdown";
|
|
775
|
+
|
|
776
|
+
export const AppProvider = ({ children }) => (
|
|
777
|
+
<MarkdownProvider
|
|
778
|
+
renderMarkdown={async (md) => {
|
|
779
|
+
// Use dynamic import to reduce the bundle size of your application
|
|
780
|
+
const { renderMarkdown } = await import('next-intlayer/markdown');
|
|
781
|
+
return renderMarkdown(md);
|
|
782
|
+
}}
|
|
783
|
+
>
|
|
784
|
+
{children}
|
|
785
|
+
</MarkdownProvider>
|
|
786
|
+
);
|
|
787
|
+
```
|
|
788
|
+
|
|
789
|
+
> Importing your Markdown renderer dynamically is a good way to reduce the bundle size of your application.
|
|
790
|
+
|
|
658
791
|
</Tab>
|
|
659
792
|
<Tab label="Vue" value="vue">
|
|
660
793
|
|
|
@@ -680,6 +813,9 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
|
|
|
680
813
|
app.mount("#app");
|
|
681
814
|
```
|
|
682
815
|
|
|
816
|
+
|
|
817
|
+
> MDX is supported — any component name used inside your Markdown (e.g. `<MyCustomJSXComponent />`) is resolved against the `components` map.
|
|
818
|
+
|
|
683
819
|
You can also use your own markdown renderer:
|
|
684
820
|
|
|
685
821
|
```typescript fileName="main.ts"
|
|
@@ -721,6 +857,9 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
|
|
|
721
857
|
</MarkdownProvider>
|
|
722
858
|
```
|
|
723
859
|
|
|
860
|
+
|
|
861
|
+
> MDX is supported — any component name used inside your Markdown (e.g. `<MyCustomJSXComponent />`) is resolved against the `components` map.
|
|
862
|
+
|
|
724
863
|
You can also use your own markdown renderer:
|
|
725
864
|
|
|
726
865
|
```svelte fileName="App.svelte"
|
|
@@ -757,6 +896,9 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
|
|
|
757
896
|
);
|
|
758
897
|
```
|
|
759
898
|
|
|
899
|
+
|
|
900
|
+
> MDX is supported — any component name used inside your Markdown (e.g. `<MyCustomJSXComponent />`) is resolved against the `components` map.
|
|
901
|
+
|
|
760
902
|
You can also use your own markdown renderer:
|
|
761
903
|
|
|
762
904
|
```tsx fileName="AppProvider.tsx"
|
|
@@ -793,6 +935,9 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
|
|
|
793
935
|
);
|
|
794
936
|
```
|
|
795
937
|
|
|
938
|
+
|
|
939
|
+
> MDX is supported — any component name used inside your Markdown (e.g. `<MyCustomJSXComponent />`) is resolved against the `components` map.
|
|
940
|
+
|
|
796
941
|
You can also use your own markdown renderer:
|
|
797
942
|
|
|
798
943
|
```tsx fileName="AppProvider.tsx"
|
|
@@ -829,6 +974,9 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
|
|
|
829
974
|
};
|
|
830
975
|
```
|
|
831
976
|
|
|
977
|
+
|
|
978
|
+
> MDX is supported — any component name used inside your Markdown (e.g. `<MyCustomJSXComponent />`) is resolved against the `components` map.
|
|
979
|
+
|
|
832
980
|
You can also use your own markdown renderer:
|
|
833
981
|
|
|
834
982
|
```typescript fileName="app.config.ts"
|
|
@@ -851,7 +999,177 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
|
|
|
851
999
|
</Tab>
|
|
852
1000
|
</Tabs>
|
|
853
1001
|
|
|
854
|
-
|
|
1002
|
+
## Suspense
|
|
1003
|
+
|
|
1004
|
+
The Intlayer Markdown renderer is dynamically loaded. Although optimized, the underlying parser chunk is approximately 55kb. Loading this synchronously delays the initial page rendering and degrades First Contentful Paint (FCP).
|
|
1005
|
+
|
|
1006
|
+
To prevent blocking the UI, Intlayer integrates with React's Suspense API. It fetches the parser in the background and throws a Promise during the download.
|
|
1007
|
+
|
|
1008
|
+
Wrap any component rendering Intlayer Markdown in a `<Suspense>` boundary. This displays a localized fallback state while the chunk downloads, allowing the rest of your DOM to render immediately.
|
|
1009
|
+
|
|
1010
|
+
Warning: If you do not provide a `<Suspense>` boundary, React will suspend at the root level or block the entire component tree from rendering until the 55kb chunk is fully loaded.
|
|
1011
|
+
|
|
1012
|
+
<Tabs>
|
|
1013
|
+
<Tab label="Next.js" value="nextjs">
|
|
1014
|
+
|
|
1015
|
+
In Next.js App Router, you can use either React `Suspense` for client components or a `loading.tsx` file for server components.
|
|
1016
|
+
|
|
1017
|
+
**Client Component:**
|
|
1018
|
+
|
|
1019
|
+
```tsx fileName="components/MyComponent.tsx"
|
|
1020
|
+
"use client";
|
|
1021
|
+
import { useIntlayer } from "next-intlayer";
|
|
1022
|
+
import { Suspense } from "react";
|
|
1023
|
+
|
|
1024
|
+
const MyComponent = () => {
|
|
1025
|
+
const markdownContent = useIntlayer("my-markdown");
|
|
1026
|
+
|
|
1027
|
+
return (
|
|
1028
|
+
<Suspense fallback={<div>Loading...</div>}>{markdownContent}</Suspense>
|
|
1029
|
+
);
|
|
1030
|
+
};
|
|
1031
|
+
```
|
|
1032
|
+
|
|
1033
|
+
**Server Component with `loading.tsx`:**
|
|
1034
|
+
|
|
1035
|
+
```tsx fileName="app/loading.tsx"
|
|
1036
|
+
export default function Loading() {
|
|
1037
|
+
return <div>Loading...</div>;
|
|
1038
|
+
}
|
|
1039
|
+
```
|
|
1040
|
+
|
|
1041
|
+
```tsx fileName="app/page.tsx"
|
|
1042
|
+
import { useIntlayer } from "next-intlayer/server";
|
|
1043
|
+
|
|
1044
|
+
const MyPage = () => {
|
|
1045
|
+
const markdownContent = useIntlayer("my-markdown");
|
|
1046
|
+
return <div>{markdownContent}</div>;
|
|
1047
|
+
};
|
|
1048
|
+
|
|
1049
|
+
export default MyPage;
|
|
1050
|
+
```
|
|
1051
|
+
|
|
1052
|
+
</Tab>
|
|
1053
|
+
|
|
1054
|
+
<Tab label="React" value="react">
|
|
1055
|
+
|
|
1056
|
+
```tsx
|
|
1057
|
+
import { useIntlayer } from "react-intlayer";
|
|
1058
|
+
import { Suspense } from "react";
|
|
1059
|
+
|
|
1060
|
+
const MyComponent = () => {
|
|
1061
|
+
const markdownContent = useIntlayer("my-markdown");
|
|
1062
|
+
|
|
1063
|
+
return (
|
|
1064
|
+
<Suspense fallback={<div>Loading...</div>}>{markdownContent}</Suspense>
|
|
1065
|
+
);
|
|
1066
|
+
};
|
|
1067
|
+
```
|
|
1068
|
+
|
|
1069
|
+
</Tab>
|
|
1070
|
+
|
|
1071
|
+
<Tab label="Vue" value="vue">
|
|
1072
|
+
|
|
1073
|
+
Vue has a built-in `<Suspense>` component. Wrap the component rendering Markdown content in a `<Suspense>` boundary.
|
|
1074
|
+
|
|
1075
|
+
```vue fileName="MyComponent.vue"
|
|
1076
|
+
<script setup>
|
|
1077
|
+
import { useIntlayer } from "vue-intlayer";
|
|
1078
|
+
|
|
1079
|
+
const { markdownContent } = useIntlayer("my-markdown");
|
|
1080
|
+
</script>
|
|
1081
|
+
|
|
1082
|
+
<template>
|
|
1083
|
+
<Suspense>
|
|
1084
|
+
<component :is="markdownContent" />
|
|
1085
|
+
<template #fallback>
|
|
1086
|
+
<div>Loading...</div>
|
|
1087
|
+
</template>
|
|
1088
|
+
</Suspense>
|
|
1089
|
+
</template>
|
|
1090
|
+
```
|
|
1091
|
+
|
|
1092
|
+
</Tab>
|
|
1093
|
+
<Tab label="Svelte" value="svelte">
|
|
1094
|
+
|
|
1095
|
+
Svelte does not have a Suspense API equivalent. Use an `{#await}` block to handle async rendering of Markdown content.
|
|
1096
|
+
|
|
1097
|
+
```svelte fileName="MyComponent.svelte"
|
|
1098
|
+
<script lang="ts">
|
|
1099
|
+
import { useIntlayer } from "svelte-intlayer";
|
|
1100
|
+
|
|
1101
|
+
const content = useIntlayer("my-markdown");
|
|
1102
|
+
</script>
|
|
1103
|
+
|
|
1104
|
+
{#await $content.markdownContent}
|
|
1105
|
+
<div>Loading...</div>
|
|
1106
|
+
{:then rendered}
|
|
1107
|
+
{@html rendered}
|
|
1108
|
+
{/await}
|
|
1109
|
+
```
|
|
1110
|
+
|
|
1111
|
+
</Tab>
|
|
1112
|
+
<Tab label="Preact" value="preact">
|
|
1113
|
+
|
|
1114
|
+
Preact supports React's Suspense API via `preact/compat`.
|
|
1115
|
+
|
|
1116
|
+
```tsx fileName="MyComponent.tsx"
|
|
1117
|
+
import { useIntlayer } from "preact-intlayer";
|
|
1118
|
+
import { Suspense } from "preact/compat";
|
|
1119
|
+
|
|
1120
|
+
const MyComponent = () => {
|
|
1121
|
+
const markdownContent = useIntlayer("my-markdown");
|
|
1122
|
+
|
|
1123
|
+
return (
|
|
1124
|
+
<Suspense fallback={<div>Loading...</div>}>{markdownContent}</Suspense>
|
|
1125
|
+
);
|
|
1126
|
+
};
|
|
1127
|
+
```
|
|
1128
|
+
|
|
1129
|
+
</Tab>
|
|
1130
|
+
<Tab label="Solid" value="solid">
|
|
1131
|
+
|
|
1132
|
+
Solid has its own `<Suspense>` component from `solid-js`.
|
|
1133
|
+
|
|
1134
|
+
```tsx fileName="MyComponent.tsx"
|
|
1135
|
+
import { useIntlayer } from "solid-intlayer";
|
|
1136
|
+
import { Suspense } from "solid-js";
|
|
1137
|
+
|
|
1138
|
+
const MyComponent = () => {
|
|
1139
|
+
const { markdownContent } = useIntlayer("my-markdown");
|
|
1140
|
+
|
|
1141
|
+
return (
|
|
1142
|
+
<Suspense fallback={<div>Loading...</div>}>{markdownContent}</Suspense>
|
|
1143
|
+
);
|
|
1144
|
+
};
|
|
1145
|
+
```
|
|
1146
|
+
|
|
1147
|
+
</Tab>
|
|
1148
|
+
<Tab label="Angular" value="angular">
|
|
1149
|
+
|
|
1150
|
+
Angular does not have a Suspense API. Use Angular's deferrable views (`@defer`) to handle lazy-loaded Markdown content (requires Angular 17+).
|
|
1151
|
+
|
|
1152
|
+
```typescript fileName="my.component.ts"
|
|
1153
|
+
import { Component } from "@angular/core";
|
|
1154
|
+
import { useIntlayer } from "angular-intlayer";
|
|
1155
|
+
|
|
1156
|
+
@Component({
|
|
1157
|
+
selector: "app-my",
|
|
1158
|
+
template: `
|
|
1159
|
+
@defer {
|
|
1160
|
+
<div [innerHTML]="content().markdownContent"></div>
|
|
1161
|
+
} @loading {
|
|
1162
|
+
<div>Loading...</div>
|
|
1163
|
+
}
|
|
1164
|
+
`,
|
|
1165
|
+
})
|
|
1166
|
+
export class MyComponent {
|
|
1167
|
+
content = useIntlayer("my-markdown");
|
|
1168
|
+
}
|
|
1169
|
+
```
|
|
1170
|
+
|
|
1171
|
+
</Tab>
|
|
1172
|
+
</Tabs>
|
|
855
1173
|
|
|
856
1174
|
## Options Reference
|
|
857
1175
|
|
|
@@ -224,7 +224,7 @@ This approach allows you to:
|
|
|
224
224
|
|
|
225
225
|
GitHub stars are a strong indicator of a project's popularity, community trust, and long-term relevance. While not a direct measure of technical quality, they reflect how many developers find the project useful, follow its progress, and are likely to adopt it. For estimating the value of a project, stars help compare traction across alternatives and provide insights into ecosystem growth.
|
|
226
226
|
|
|
227
|
-
[](https://www.star-history.com/#aymericzip/intlayer&formatjs/formatjs&i18next/react-i18next&i18next/i18next&i18next/next-i18next&lingui/js-lingui&amannn/next-intl&intlify/vue-i18n&codingcommons/typesafe-i18n&opral/paraglide-js)
|
|
228
228
|
|
|
229
229
|
---
|
|
230
230
|
|