|
| 1 | +import React from "react"; |
| 2 | +import AdmonitionTypeNote from "@theme/Admonition/Type/Note"; |
| 3 | +import AdmonitionTypeTip from "@theme/Admonition/Type/Tip"; |
| 4 | +import AdmonitionTypeInfo from "@theme/Admonition/Type/Info"; |
| 5 | +import AdmonitionTypeCaution from "@theme/Admonition/Type/Caution"; |
| 6 | +import AdmonitionTypeDanger from "@theme/Admonition/Type/Danger"; |
| 7 | +import AdmonitionTypeJoke from "@theme/Admonition/Type/Joke"; |
| 8 | +import type AdmonitionTypes from "@theme/Admonition/Types"; |
| 9 | +import type { Props } from "@theme/Admonition"; |
| 10 | + |
| 11 | +const admonitionTypes: typeof AdmonitionTypes = { |
| 12 | + note: AdmonitionTypeNote, |
| 13 | + tip: AdmonitionTypeTip, |
| 14 | + info: AdmonitionTypeInfo, |
| 15 | + caution: AdmonitionTypeCaution, |
| 16 | + danger: AdmonitionTypeDanger, |
| 17 | + joke: AdmonitionTypeJoke, |
| 18 | +}; |
| 19 | + |
| 20 | +// Undocumented legacy admonition type aliases |
| 21 | +// Provide hardcoded/untranslated retrocompatible label |
| 22 | +// See also https://github.com/facebook/docusaurus/issues/7767 |
| 23 | +const admonitionAliases: typeof AdmonitionTypes = { |
| 24 | + secondary: (props: Props) => ( |
| 25 | + <AdmonitionTypeNote title="secondary" {...props} /> |
| 26 | + ), |
| 27 | + joke: (props: Props) => <AdmonitionTypeJoke title="joke" {...props} />, |
| 28 | + important: (props: Props) => ( |
| 29 | + <AdmonitionTypeInfo title="important" {...props} /> |
| 30 | + ), |
| 31 | + success: (props: Props) => <AdmonitionTypeTip title="success" {...props} />, |
| 32 | + // TODO bad legacy mapping, warning is usually yellow, not red... |
| 33 | + warning: (props: Props) => ( |
| 34 | + <AdmonitionTypeDanger title="warning" {...props} /> |
| 35 | + ), |
| 36 | +}; |
| 37 | + |
| 38 | +export default { |
| 39 | + ...admonitionTypes, |
| 40 | + ...admonitionAliases, |
| 41 | +}; |
0 commit comments