Add a way for consumers to pass custom components for MDX parsing
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 45/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- typescript
調査の方向性
src/pages/[section]/[...page].astro:84-106 と src/pages/[section]/[page]/[tab].astro:116-137 のコンポーネント props から始め、次に pf-docs.config.mjs:44 と cli/convertToMDX.ts:48-52 を読みます。設定と import の保持のどちらにするかを決め、カスタムコンポーネントが一般的な MDX と LiveExample のコンテンツで動作し、組み込みの解決を維持し、TypeScript をサポートし、ドキュメント化されていることを確認します。
索引モデルが issue の本文から書いたものです。
説明
Problem Summary
Consumers cannot use custom components directly within their MDX/markdown files. The MDX component mapping is hardcoded in the Astro page files ([...page].astro and [tab].astro), preventing users from injecting custom components like PatternFly's [Alert /] into their documentation content.
Current limitation: While the scope config option (in pf-docs.config.mjs) allows passing custom components for use within [LiveExample] blocks, there's no way to use custom components in the general MDX content outside of examples.
Use Case
When integrating docs-core v1.20.0, consumers need to:
-
Use PatternFly components (Alert, Banner, etc.) directly in markdown content for callouts and warnings
-
Import custom documentation components for specialized content rendering
-
Include organization-specific UI components in documentation pages
-
Render interactive widgets or diagrams inline with documentation
Example of desired usage:
h1. Component Documentation
[Alert variant="warning" title="Important Note"]
This component is deprecated. Use the new version instead.
[/Alert]
Rest of documentation content...
Current Architecture
MDX components are provided via the components prop on the [Content /] component in Astro page files:
// src/pages/[section]/[...page].astro:84-106
[Content
components={{
SectionGallery,
h1, h2, h3, h4, h5, h6,
p, a, small, blockquote,
pre, hr, ul, ol, dl, li, dt, dd,
LiveExample,
}}
/]
Why this is hardcoded:
-
The
componentsobject maps MDX elements to React/Astro components -
Currently only includes HTML elements,
LiveExample, andSectionGallery -
No mechanism to merge in user-provided components from config
Related scope mechanism:
-
pf-docs.config.mjshas ascopeproperty forLiveExamplecomponents -
LiveExample.tsx:35-43mergesconfig.scopewith built-in PatternFly components -
This only applies to code inside
[LiveExample]blocks, not general MDX content
MDX import stripping:
The convertToMDX process (cli/convertToMDX.ts:48-52) also removes absolute imports, which would prevent direct imports even if components were available:
function removeExistingImports(content: string): string {
// Remove imports that are absolute and not CSS
const importRegex = /^import {?[\w\s,\n]_}? from ['"|?!\.\.?\/](?!._\.css['"])[^'"]*['"];?\n/gm
return content.replace(importRegex, '')
}
Potential Approaches
Two options have been identified:
-
Configuration-based approach: Enable consumers to specify custom components through the pf-docs configuration file that become available globally in MDX files
-
Import preservation approach: Modify the MDX conversion process to retain certain component imports in markdown files, while selectively removing only imports used exclusively in LiveExamples
Completion Criteria
The issue is resolved when:
- Custom components in MDX: Consumers can use custom components directly in MDX content outside of
[LiveExample]blocks - Configuration support: Clear mechanism (config or import-based) for registering custom components
- Component merging: User-provided components are merged with built-in components in the
[Content /]components prop - LiveExample compatibility: Custom components work in both general MDX content and within
[LiveExample]scopes - No conflicts: Custom components don't interfere with built-in component resolution or auto-generated imports
- Type safety: Proper TypeScript support for custom component registration
- Documentation: Clear examples showing how to register and use custom components
Technical Notes
-
File locations needing changes:
-
src/pages/[section]/[...page].astro:84-106(components prop) -
src/pages/[section]/[page]/[tab].astro:116-137(components prop) -
cli/convertToMDX.ts:48-52(if using import preservation approach) -
Existing scope config:
pf-docs.config.mjs:44has ascopeproperty (currently only for LiveExample) -
MDX components are provided via Astro's
[Content components={{...}} /]pattern -
Astro docs: https://docs.astro.build/en/guides/markdown-content/#custom-components-with-imported-mdx
Related Links
- Jira: PF-3606
Jira Issue: PF-3654
- 主要言語
- TypeScript
- スター
- 3
- フォーク
- 11
- 平均マージ
- 4日 18時間
- マージ済み PR(30日)
- 2
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
patternfly/patternfly-doc-core のほかの issue
-
api
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
-
Update patternfly packages to pull in the component schemas from doc core再び着手できるかも @dlabaj が 46 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
patternfly/patternfly-doc-core#236 · コメント 1 件 · リアクション 1 件 · 担当者 1 名 ·
-
Bug: Version of api is not being updated.再び着手できるかも @dlabaj が 95 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンbug PF Team
patternfly/patternfly-doc-core#233 · 担当者 1 名 ·
-
PF Team
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
-
PF Team
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
patternfly/patternfly-doc-core の issue をすべて見る
似ている issue
-
by: ai-assisted frontend good-for: new-member spike
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Northeastern-Electric-Racing/Argos#847 ·
メンテナーはふだん 4 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 84/100
SignalK/freeboard-sk#990 ·
メンテナーはふだん 1 日以内に返信
-
[missing-inheritance] audit review (1 preset)対応中かも @github-actions が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
osmberlin/tagging-schema-browser#363 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Albert-Weasker/niubigeo#205 ·
メンテナーはふだん 1 日以内に返信
-
area/frontend area/v2 kind/bug priority/needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
kubeflow/notebooks#1498 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信