forked from aws-amplify/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mdx-components.tsx
76 lines (72 loc) · 2.43 KB
/
mdx-components.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import * as React from 'react';
import type { MDXComponents } from 'mdx/types';
import ExportedImage from 'next-image-export-optimizer';
import InlineFilter from './src/components/InlineFilter';
import { YoutubeEmbed } from './src/components/YoutubeEmbed';
import { Accordion } from './src/components/Accordion';
import { Block, BlockSwitcher } from './src/components/BlockSwitcher';
import { Callout } from './src/components/Callout';
import Fragments from './src/components/Fragments';
import {
MDXCode,
MDXHeading,
MDXLink,
MDXTable
} from './src/components/MDXComponents';
import { MigrationAlert } from './src/components/MigrationAlert';
import preToCodeBlock from './src/utils/pre-to-code-block';
import { Overview } from './src/components/Overview';
import ExternalLink from './src/components/ExternalLink';
import { ExternalLinkButton } from './src/components/ExternalLinkButton';
import { InternalLinkButton } from './src/components/InternalLinkButton';
import { Grid, View } from '@aws-amplify/ui-react';
import { Columns } from './src/components/Columns';
import { Video } from './src/components/Video';
const ResponsiveImage = (props) => (
<ExportedImage style={{ height: 'auto' }} {...props} />
);
const MDXHeading1 = (props) => <MDXHeading level={1} {...props} />;
const MDXHeading2 = (props) => <MDXHeading level={2} {...props} />;
const MDXHeading3 = (props) => <MDXHeading level={3} {...props} />;
const MDXHeading4 = (props) => <MDXHeading level={4} {...props} />;
const MDXHeading5 = (props) => <MDXHeading level={5} {...props} />;
const MDXHeading6 = (props) => <MDXHeading level={6} {...props} />;
export function useMDXComponents(components: MDXComponents): MDXComponents {
return {
// Map markdown elements to custom components
a: MDXLink,
h1: MDXHeading1,
h2: MDXHeading2,
h3: MDXHeading3,
h4: MDXHeading4,
h5: MDXHeading5,
h6: MDXHeading6,
pre: (preProps) => {
const props = preToCodeBlock(preProps);
if (props) {
return <MDXCode {...props} />;
}
return <pre {...preProps} />;
},
img: ResponsiveImage,
table: MDXTable,
// Make common custom components available to content authors
Accordion,
Block,
BlockSwitcher,
Callout,
Fragments,
InlineFilter,
MigrationAlert,
YoutubeEmbed,
Overview,
ExternalLink,
ExternalLinkButton,
InternalLinkButton,
Grid,
Columns,
Video,
View,
...components
};
}