Commit bfe7bd8
authored
Externalize using create() and drop size threshold requirement (#1280)
* refactor(plugin): externalize JSON props at source in create()
Implements slorber's suggestion from PR #1279 to handle externalization
at the source (in create()) rather than post-processing MDX strings.
Changes:
- Add externalization context system to utils.ts
- Modify create() to detect large JSON props and externalize inline
- Remove externalizeJsonProps.ts (no longer needed)
- Update index.ts to use context-based approach
This is more architecturally clean as the externalization decision
happens where the component is created, not via regex parsing afterward.
* refactor(plugin): drop size threshold for externalization
Always externalize eligible props (responses, parameters, body, schema)
regardless of size. This simplifies the logic and provides consistent
behavior - users either have externalization on or off, no edge cases.
* refactor(plugin): use one JSON file per component with spread props
Implements slorber's suggestion to externalize all props for a component
into a single JSON file and use spread syntax:
<StatusCodes {...require('./add-pet.StatusCodes.json')} />
Instead of separate files per prop:
<StatusCodes responses={require('./add-pet.responses.json')} />
Benefits:
- Cleaner file organization (one file per component vs per prop)
- Simpler logic (no need to track which props to externalize)
- All props for a component are colocated in one file
* refactor(plugin): use runWithExternalization wrapper for cleaner API
Provides a cleaner API similar to AsyncLocalStorage pattern but uses
module-level state internally (AsyncLocalStorage isn't available in
browser bundles that Docusaurus creates).
The runWithExternalization() function wraps generation with try/finally
to ensure context is always cleaned up, providing the same safety
guarantees as AsyncLocalStorage.run().1 parent 77f891e commit bfe7bd8
File tree
3 files changed
+188
-251
lines changed- packages/docusaurus-plugin-openapi-docs/src
- markdown
3 files changed
+188
-251
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 24 | + | |
28 | 25 | | |
29 | 26 | | |
30 | 27 | | |
| |||
337 | 334 | | |
338 | 335 | | |
339 | 336 | | |
340 | | - | |
341 | | - | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
342 | 352 | | |
343 | 353 | | |
344 | 354 | | |
| |||
388 | 398 | | |
389 | 399 | | |
390 | 400 | | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
409 | 409 | | |
410 | 410 | | |
411 | 411 | | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
| 412 | + | |
417 | 413 | | |
418 | 414 | | |
419 | 415 | | |
| |||
499 | 495 | | |
500 | 496 | | |
501 | 497 | | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
520 | 508 | | |
521 | 509 | | |
522 | 510 | | |
| |||
Lines changed: 0 additions & 201 deletions
This file was deleted.
0 commit comments