|
| 1 | +/** |
| 2 | + * Copyright (c) Facebook, Inc. and its affiliates. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + */ |
| 7 | + |
| 8 | +import React from 'react'; |
| 9 | +import clsx from 'clsx'; |
| 10 | +import Translate from '@docusaurus/Translate'; |
| 11 | +import {ThemeClassNames} from '@docusaurus/theme-common'; |
| 12 | +import {useDocsVersion, useDoc} from '@docusaurus/plugin-content-docs/client'; |
| 13 | +import type {Props} from '@theme/DocVersionBadge'; |
| 14 | +import TagsListInline from '@theme/TagsListInline'; |
| 15 | +// Import the original mapper |
| 16 | +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; // Import the FontAwesomeIcon component. |
| 17 | +import { library } from '@fortawesome/fontawesome-svg-core'; // Import the library component. |
| 18 | +import { fab } from '@fortawesome/free-brands-svg-icons'; // Import all brands icons. |
| 19 | +import { far, faCircleQuestion } from '@fortawesome/free-regular-svg-icons'; // Import all solid icons. |
| 20 | +import { fas } from '@fortawesome/free-solid-svg-icons'; // Import all solid icons. |
| 21 | + |
| 22 | +library.add(fab, fas, far, faCircleQuestion); // Add all icons to the library so you can use them without importing them individually. |
| 23 | + |
| 24 | +export default function DocVersionBadge({ |
| 25 | + className, |
| 26 | +}: Props): JSX.Element | null { |
| 27 | + |
| 28 | + const {metadata} = useDoc(); |
| 29 | + const {tags} = metadata; |
| 30 | + |
| 31 | + const versionMetadata = useDocsVersion(); |
| 32 | + if (versionMetadata.badge) { |
| 33 | + return ( |
| 34 | + <span |
| 35 | + className={clsx( |
| 36 | + className, |
| 37 | + ThemeClassNames.docs.docVersionBadge, |
| 38 | + 'badge badge--secondary', |
| 39 | + )}> |
| 40 | + <Translate |
| 41 | + id="theme.docs.versionBadge.label" |
| 42 | + values={{versionLabel: versionMetadata.label}}> |
| 43 | + {'Version: {versionLabel}'} |
| 44 | + </Translate> |
| 45 | + <div |
| 46 | + className={clsx( |
| 47 | + 'row margin-top--sm', |
| 48 | + ThemeClassNames.docs.docFooterTagsRow, |
| 49 | + )}> |
| 50 | + <div className="col"> |
| 51 | + <TagsListInline tags={tags} /> |
| 52 | + <a href="https://scalar-labs.com/pricing/" target="_blank" className="fa-solid fa-circle-question tooltip"><FontAwesomeIcon icon={faCircleQuestion} size="lg" /><span className="tooltiptext">Features and pricing</span></a> |
| 53 | + </div> |
| 54 | + </div> |
| 55 | + </span> |
| 56 | + ); |
| 57 | + } |
| 58 | + return null; |
| 59 | +} |
0 commit comments