@@ -117,26 +117,22 @@ mdObj.data // => The component source code index object, the sample source
117
117
``` js
118
118
{
119
119
data: {
120
- 17 : {
121
- code: " \" use strict\" ;\n\n function ......"
122
- language: " jsx"
123
- name: 17 ,
124
- value: " impo....."
125
- },
126
120
77 : {
127
121
code: " \" use strict\" ;\n\n function ......"
128
122
language: " jsx"
129
- name: 17 ,
123
+ name: 77 ,
124
+ meta: {},
130
125
value: " impo....."
131
126
},
132
127
demo12: {
133
128
code: " \" use strict\" ;\n\n function ......"
134
129
language: " jsx"
135
- name: 17 ,
130
+ name: ' demo12' ,
131
+ meta: {},
136
132
value: " impo....."
137
133
}
138
134
},
139
- components: { 17 : ƒ, 77 : ƒ, demo12: ƒ },
135
+ components: { 77 : ƒ, demo12: ƒ },
140
136
source: " # Alert 确认对话框...."
141
137
}
142
138
```
@@ -151,6 +147,8 @@ export type CodeBlockItem = {
151
147
language? : string ;
152
148
/** The index name, which can be customized, can be a row number. */
153
149
name? : string | number ;
150
+ /** The `meta` parameter is converted into an `object`. */
151
+ meta? : Record <string , string >;
154
152
};
155
153
156
154
export type CodeBlockData = {
@@ -179,6 +177,44 @@ getMetaId('mdx:preview') // => ''
179
177
getMetaId (' mdx:preview:demo12' ) // => 'demo12'
180
178
```
181
179
180
+ ## getURLParameters
181
+
182
+ ``` js
183
+ import { getURLParameters } from ' markdown-react-code-preview-loader' ;
184
+
185
+ getURLParameters (' name=Adam&surname=Smith' ) // => { name: 'Adam', surname: "Smith" }
186
+ getURLParameters (' mdx:preview:demo12' ) // => { }
187
+ getURLParameters (' mdx:preview:demo12&name=Adam&surname=Smith' ) // => { name: 'Adam', surname: "Smith" }
188
+ getURLParameters (' mdx:preview:demo12&code=true&boreder=0' ) // => { code: 'true', boreder: "0" }
189
+ ```
190
+
191
+ ``` markdown
192
+ \```tsx mdx:preview:demo12&code=true&boreder=0
193
+ import React from "react"
194
+ const Demo = ()=>{
195
+ return <div>测试</div>
196
+ }
197
+
198
+ export default Demo
199
+ \```
200
+ ```
201
+
202
+ ``` js
203
+ {
204
+ data: {
205
+ demo12: {
206
+ code: " \" use strict\" ;\n\n function ......"
207
+ language: " jsx"
208
+ name: ' demo12' ,
209
+ meta: { code: ' true' , boreder: ' 0' },
210
+ value: " impo....."
211
+ }
212
+ },
213
+ components: { demo12: ƒ },
214
+ source: " # Alert 确认对话框...."
215
+ }
216
+ ```
217
+
182
218
## getCodeBlock
183
219
184
220
``` ts
@@ -192,6 +228,7 @@ Note ⚠️: You need to add a special `meta` identifier to the code block examp
192
228
1 . ` mdx: ` special identifier prefix
193
229
2 . ` mdx:preview ` Controls whether to perform example indexing, and obtain the required example object through the corresponding line number.
194
230
3 . ` mdx:preview:demo12 ` Uniquely identified by ` demo12 ` , accurately obtain the ` example code ` or ` example component object ` of the index.
231
+ 4 . ` mdx:preview:&code=true&border=0 ` pass the parameters for the rendering layer to use.
195
232
196
233
``` markdown
197
234
\```tsx mdx:preview
@@ -215,6 +252,17 @@ export default Demo
215
252
\```
216
253
```
217
254
255
+ ``` markdown
256
+ \```tsx mdx:preview:demo12&code=true&boreder=0
257
+ import React from "react"
258
+ const Demo = ()=>{
259
+ return <div>测试</div>
260
+ }
261
+
262
+ export default Demo
263
+ \```
264
+ ```
265
+
218
266
## Development
219
267
220
268
``` bash
0 commit comments