@@ -22,103 +22,103 @@ function normalizeUrl(url: string, fragment?: string) {
2222 return WEBSITE_BASE + url + normalizedFragment ;
2323}
2424
25+ const config : UIToolkitConfig = {
26+ Chapter,
27+ Section : ( { children, title } ) => (
28+ < Fragment >
29+ < h3 > { title } </ h3 >
30+ { children }
31+ </ Fragment >
32+ ) ,
33+ Header,
34+ List : ( { children, type = 'decimal' } ) => (
35+ < ol style = { { listStyleType : type } } > { children } </ ol >
36+ ) ,
37+ ListItem : ( { children } ) => < li > { children } </ li > ,
38+ Paragraph : ( { children } ) => < p > { children } </ p > ,
39+ Bold : ( { children } ) => < strong > { children } </ strong > ,
40+ RenderHtmlCard : ( {
41+ caption,
42+ snippet,
43+ expoSource,
44+ title,
45+ props,
46+ preferHtmlSrc,
47+ extraneousDeps,
48+ snapshot
49+ } ) => {
50+ const html = ( props . source as HTMLSourceInline ) . html ;
51+ return (
52+ < renderhtmlcard
53+ preferHtmlSrc = { preferHtmlSrc }
54+ html = { html }
55+ title = { title }
56+ caption = { caption }
57+ snippet = { snippet }
58+ expoSource = { expoSource }
59+ extraneousDeps = { extraneousDeps }
60+ snapshot = { snapshot }
61+ />
62+ ) ;
63+ } ,
64+ SourceDisplay : ( props ) => < codeblockds { ...props } /> ,
65+ TNodeTransformDisplay : ( { snaphost, ...props } ) => {
66+ return < tnodetransformdisplay snapshot = { snaphost } { ...props } /> ;
67+ } ,
68+ Admonition : ( { children, type, title } ) => (
69+ < admonition type = { type } title = { title } >
70+ { children }
71+ </ admonition >
72+ ) ,
73+ RefBuilder : ( { name, url, type } ) => {
74+ return < reference full = { false } name = { name } url = { url } type = { type } /> ;
75+ } ,
76+ RefDoc : ( { target, children, fragment } ) => {
77+ const linkFragments =
78+ target . group === 'root'
79+ ? [ '/docs' , target . id ]
80+ : [ '/docs' , target . group , target . id ] ;
81+ return (
82+ < reference
83+ library = "react-native-render-html"
84+ name = { ( children as string ) || target . title }
85+ url = { normalizeUrl ( linkFragments . join ( '/' ) , fragment ) }
86+ type = { 'doc' }
87+ full = { false }
88+ />
89+ ) ;
90+ } ,
91+ Acronym : ( { fullName, name, definition } ) => (
92+ < abbr about = { definition } children = { name } title = { fullName } />
93+ ) ,
94+ SvgFigure : ( { asset, description, title } ) => (
95+ < svgfigure asset = { asset } title = { title } description = { description } />
96+ ) ,
97+ InlineCode : ( { children } ) => < code > { children } </ code > ,
98+ Hyperlink : ( { children, url } ) => < a href = { url } > { children } </ a > ,
99+ RefAPI : ( { library, name, url, member, full, plural } ) => {
100+ const isRNProp = url . match ( / ^ \/ a p i \/ r e n d e r h t m l p r o p s / ) ;
101+ return (
102+ < reference
103+ library = { library }
104+ name = { name }
105+ url = { normalizeUrl ( url , member ?. toLowerCase ( ) ) }
106+ member = { member }
107+ full = { full || false }
108+ type = { isRNProp ? 'rnrh-prop' : 'api-def' }
109+ plural = { plural }
110+ />
111+ ) ;
112+ } ,
113+ DList : ( { children } ) => < dl > { children } </ dl > ,
114+ DListTitle : ( { children } ) => < dt > { children } </ dt > ,
115+ DListItem : ( { children } ) => < dd > { children } </ dd > ,
116+ Conditional : ( { platform, children } ) =>
117+ platform === 'web' ? < Fragment > { children } </ Fragment > : null
118+ } ;
119+
25120export default function MdxToolkitProvider ( {
26121 children : toolkitChildren
27122} : PropsWithChildren < { } > ) {
28- const config : UIToolkitConfig = {
29- Chapter,
30- Section : ( { children, title } ) => (
31- < Fragment >
32- < h3 > { title } </ h3 >
33- { children }
34- </ Fragment >
35- ) ,
36- Header,
37- List : ( { children, type = 'decimal' } ) => (
38- < ol style = { { listStyleType : type } } > { children } </ ol >
39- ) ,
40- ListItem : ( { children } ) => < li > { children } </ li > ,
41- Paragraph : ( { children } ) => < p > { children } </ p > ,
42- Bold : ( { children } ) => < strong > { children } </ strong > ,
43- RenderHtmlCard : ( {
44- caption,
45- snippet,
46- expoSource,
47- title,
48- props,
49- preferHtmlSrc,
50- extraneousDeps,
51- snapshot
52- } ) => {
53- const html = ( props . source as HTMLSourceInline ) . html ;
54- return (
55- < renderhtmlcard
56- preferHtmlSrc = { preferHtmlSrc }
57- html = { html }
58- title = { title }
59- caption = { caption }
60- snippet = { snippet }
61- expoSource = { expoSource }
62- extraneousDeps = { extraneousDeps }
63- snapshot = { snapshot }
64- />
65- ) ;
66- } ,
67- SourceDisplay : ( props ) => < codeblockds { ...props } /> ,
68- TNodeTransformDisplay : ( { snaphost, ...props } ) => {
69- return < tnodetransformdisplay snapshot = { snaphost } { ...props } /> ;
70- } ,
71- Admonition : ( { children, type, title } ) => (
72- < admonition type = { type } title = { title } >
73- { children }
74- </ admonition >
75- ) ,
76- RefBuilder : ( { name, url, type } ) => {
77- return < reference full = { false } name = { name } url = { url } type = { type } /> ;
78- } ,
79- RefDoc : ( { target, children, fragment } ) => {
80- const linkFragments =
81- target . group === 'root'
82- ? [ '/docs' , target . id ]
83- : [ '/docs' , target . group , target . id ] ;
84- return (
85- < reference
86- library = "react-native-render-html"
87- name = { ( children as string ) || target . title }
88- url = { normalizeUrl ( linkFragments . join ( '/' ) , fragment ) }
89- type = { 'doc' }
90- full = { false }
91- />
92- ) ;
93- } ,
94- Acronym : ( { fullName, name, definition } ) => (
95- < abbr about = { definition } children = { name } title = { fullName } />
96- ) ,
97- SvgFigure : ( { asset, description, title } ) => (
98- < svgfigure asset = { asset } title = { title } description = { description } />
99- ) ,
100- InlineCode : ( { children } ) => < code > { children } </ code > ,
101- Hyperlink : ( { children, url } ) => < a href = { url } > { children } </ a > ,
102- // eslint-disable-next-line @typescript-eslint/no-unused-vars
103- RefAPI : ( { library, name, url, member, full, plural } ) => {
104- const isRNProp = url . match ( / ^ \/ a p i \/ r e n d e r h t m l p r o p s / ) ;
105- return (
106- < reference
107- library = { library }
108- name = { name }
109- url = { normalizeUrl ( url , member ?. toLowerCase ( ) ) }
110- member = { member }
111- full = { full || false }
112- type = { isRNProp ? 'rnrh-prop' : 'api-def' }
113- plural = { plural }
114- />
115- ) ;
116- } ,
117- DList : ( { children } ) => < dl > { children } </ dl > ,
118- DListTitle : ( { children } ) => < dt > { children } </ dt > ,
119- DListItem : ( { children } ) => < dd > { children } </ dd > ,
120- Conditional : ( { platform, children } ) =>
121- platform === 'web' ? < Fragment > { children } </ Fragment > : null
122- } ;
123123 return < ToolkitProvider config = { config } > { toolkitChildren } </ ToolkitProvider > ;
124124}
0 commit comments