@intlayer/docs 8.10.0 → 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.
Files changed (43) hide show
  1. package/docs/ar/dictionary/markdown.md +336 -7
  2. package/docs/ar/interest_of_intlayer.md +1 -1
  3. package/docs/bn/interest_of_intlayer.md +1 -1
  4. package/docs/cs/interest_of_intlayer.md +1 -1
  5. package/docs/de/dictionary/markdown.md +336 -7
  6. package/docs/de/interest_of_intlayer.md +1 -1
  7. package/docs/en/dictionary/markdown.md +322 -8
  8. package/docs/en/interest_of_intlayer.md +1 -1
  9. package/docs/en-GB/dictionary/markdown.md +336 -7
  10. package/docs/en-GB/interest_of_intlayer.md +1 -1
  11. package/docs/es/dictionary/markdown.md +336 -7
  12. package/docs/es/interest_of_intlayer.md +1 -1
  13. package/docs/fr/dictionary/markdown.md +336 -7
  14. package/docs/fr/interest_of_intlayer.md +1 -1
  15. package/docs/hi/dictionary/markdown.md +336 -7
  16. package/docs/hi/interest_of_intlayer.md +1 -1
  17. package/docs/id/dictionary/markdown.md +336 -7
  18. package/docs/id/interest_of_intlayer.md +1 -1
  19. package/docs/it/dictionary/markdown.md +336 -7
  20. package/docs/it/interest_of_intlayer.md +1 -1
  21. package/docs/ja/interest_of_intlayer.md +1 -1
  22. package/docs/ko/dictionary/markdown.md +336 -7
  23. package/docs/ko/interest_of_intlayer.md +1 -1
  24. package/docs/nl/interest_of_intlayer.md +1 -1
  25. package/docs/pl/dictionary/markdown.md +336 -7
  26. package/docs/pl/interest_of_intlayer.md +1 -1
  27. package/docs/pt/benchmark/solid.md +1 -1
  28. package/docs/pt/benchmark/svelte.md +1 -1
  29. package/docs/pt/dictionary/markdown.md +336 -7
  30. package/docs/pt/interest_of_intlayer.md +1 -1
  31. package/docs/ru/dictionary/markdown.md +445 -3
  32. package/docs/ru/interest_of_intlayer.md +1 -1
  33. package/docs/tr/dictionary/markdown.md +336 -7
  34. package/docs/tr/interest_of_intlayer.md +1 -1
  35. package/docs/uk/dictionary/markdown.md +336 -7
  36. package/docs/uk/interest_of_intlayer.md +1 -1
  37. package/docs/ur/interest_of_intlayer.md +1 -1
  38. package/docs/vi/dictionary/markdown.md +336 -7
  39. package/docs/vi/interest_of_intlayer.md +1 -1
  40. package/docs/zh/dictionary/markdown.md +336 -7
  41. package/docs/zh/interest_of_intlayer.md +1 -1
  42. package/docs/zh-TW/interest_of_intlayer.md +1 -1
  43. package/package.json +7 -7
@@ -134,8 +134,6 @@ You can declare Markdown content using the `md` function or simply as a string (
134
134
 
135
135
  </Tabs>
136
136
 
137
- ---
138
-
139
137
  ## Rendering Markdown
140
138
 
141
139
  Intlayer provides two independent ways to render Markdown:
@@ -151,7 +149,7 @@ Markdown rendering supports **MDX** — use any JSX/framework component by name
151
149
  ### 1. Automatic Rendering (via `useIntlayer`)
152
150
 
153
151
  <Tabs group="framework">
154
- <Tab label="React / Next.js" value="react">
152
+ <Tab label="React" value="react">
155
153
  Markdown nodes can be rendered directly as JSX.
156
154
 
157
155
  ```tsx fileName="App.tsx"
@@ -201,6 +199,57 @@ Markdown rendering supports **MDX** — use any JSX/framework component by name
201
199
  {myMarkdownContent.metadata.title}
202
200
  ```
203
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
+
204
253
  </Tab>
205
254
  <Tab label="Vue" value="vue">
206
255
  In Vue, Markdown content can be rendered using the `component` built-in or directly as a node.
@@ -445,7 +494,7 @@ Markdown rendering supports **MDX** — use any JSX/framework component by name
445
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.
446
495
 
447
496
  <Tabs group="framework">
448
- <Tab label="React / Next.js" value="react">
497
+ <Tab label="React" value="react">
449
498
 
450
499
  #### `<MarkdownRenderer />` Component
451
500
 
@@ -483,6 +532,45 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
483
532
  const jsx = renderMarkdown("# My Title", { forceBlock: true });
484
533
  ```
485
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
+
486
574
  </Tab>
487
575
  <Tab label="Vue" value="vue">
488
576
 
@@ -612,14 +700,12 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
612
700
  </Tab>
613
701
  </Tabs>
614
702
 
615
- ---
616
-
617
703
  ## Global Configuration with `MarkdownProvider`
618
704
 
619
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.
620
706
 
621
707
  <Tabs group="framework">
622
- <Tab label="React / Next.js" value="react">
708
+ <Tab label="React" value="react">
623
709
 
624
710
  ```tsx fileName="AppProvider.tsx"
625
711
  import { MarkdownProvider } from "react-intlayer/markdown";
@@ -637,6 +723,7 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
637
723
  );
638
724
  ```
639
725
 
726
+
640
727
  > MDX is supported — any component name used inside your Markdown (e.g. `<MyCustomJSXComponent />`) is resolved against the `components` map.
641
728
 
642
729
  You can also use your own markdown renderer:
@@ -659,6 +746,48 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
659
746
 
660
747
  > Importing your Markdown renderer dynamically is a good way to reduce the bundle size of your application.
661
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
+
662
791
  </Tab>
663
792
  <Tab label="Vue" value="vue">
664
793
 
@@ -684,6 +813,9 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
684
813
  app.mount("#app");
685
814
  ```
686
815
 
816
+
817
+ > MDX is supported — any component name used inside your Markdown (e.g. `<MyCustomJSXComponent />`) is resolved against the `components` map.
818
+
687
819
  You can also use your own markdown renderer:
688
820
 
689
821
  ```typescript fileName="main.ts"
@@ -725,6 +857,9 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
725
857
  </MarkdownProvider>
726
858
  ```
727
859
 
860
+
861
+ > MDX is supported — any component name used inside your Markdown (e.g. `<MyCustomJSXComponent />`) is resolved against the `components` map.
862
+
728
863
  You can also use your own markdown renderer:
729
864
 
730
865
  ```svelte fileName="App.svelte"
@@ -761,6 +896,9 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
761
896
  );
762
897
  ```
763
898
 
899
+
900
+ > MDX is supported — any component name used inside your Markdown (e.g. `<MyCustomJSXComponent />`) is resolved against the `components` map.
901
+
764
902
  You can also use your own markdown renderer:
765
903
 
766
904
  ```tsx fileName="AppProvider.tsx"
@@ -797,6 +935,9 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
797
935
  );
798
936
  ```
799
937
 
938
+
939
+ > MDX is supported — any component name used inside your Markdown (e.g. `<MyCustomJSXComponent />`) is resolved against the `components` map.
940
+
800
941
  You can also use your own markdown renderer:
801
942
 
802
943
  ```tsx fileName="AppProvider.tsx"
@@ -833,6 +974,9 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
833
974
  };
834
975
  ```
835
976
 
977
+
978
+ > MDX is supported — any component name used inside your Markdown (e.g. `<MyCustomJSXComponent />`) is resolved against the `components` map.
979
+
836
980
  You can also use your own markdown renderer:
837
981
 
838
982
  ```typescript fileName="app.config.ts"
@@ -855,7 +999,177 @@ These utilities render **raw Markdown strings** and are independent of `useIntla
855
999
  </Tab>
856
1000
  </Tabs>
857
1001
 
858
- ---
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>
859
1173
 
860
1174
  ## Options Reference
861
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
- [![Star History Chart](https://api.star-history.com/chart?repos=formatjs/formatjs%2Ci18next/react-i18next%2Ci18next/i18next%2Ci18next/next-i18next%2Clingui/js-lingui%2Camannn/next-intl%2Cintlify/vue-i18n%2Caymericzip/intlayer%2Copral/inlang&type=date&legend=top-left)](https://www.star-history.com/#formatjs/formatjs&i18next/react-i18next&i18next/i18next&i18next/next-i18next&lingui/js-lingui&amannn/next-intl&intlify/vue-i18n&opral/paraglide-js&aymericzip/intlayer)
227
+ [![Star History Chart](https://api.star-history.com/chart?repos=aymericzip/intlayer%2Cformatjs/formatjs%2Ci18next/react-i18next%2Ci18next/i18next%2Ci18next/next-i18next%2Clingui/js-lingui%2Camannn/next-intl%2Cintlify/vue-i18n%2Ccodingcommons/typesafe-i18n%2Copral/paraglide-js&type=date&legend=top-left)](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