カスタムコンポーネントに渡された値
カスタムコンポーネントで、markdown から呼び出したときの情報の取得についてのまとめ。
サマリ
| # | 取得元 | Markdown上の記載 HTML レンダリング結果 |
|---|---|---|
| 1 | なにも取得しない | <SampleTagGetNothing/> これは引数を受け取らないサンプルです |
| 2 | 属性から取得する | <SampleTagGetAttrs attr1="あー" attr2="あいう" /> attr1 は [ あー ]で、attr2 は [ あいう ] です |
| 3 | タグ内から取得する | <SampleTagGetChildren>あああ</SampleTagGetChildren> タグ内の文字は [ あああ ] です |
1. なにも取得しない
コード
md
import SampleTagGetNothing from '@site/src/components/SampleTagGetNothing';
<SampleTagGetNothing/>
src/components/SampleTagGetNothing.tsx
import React from 'react';
const SampleTagGetNothing: React.FC = () => {
return <span className="sample-highlight">これは引数を受け取らないサンプルです</span>;
};
export default SampleTagGetNothing;