forked from newrelic/docs-website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMDXContainer.js
More file actions
153 lines (148 loc) · 4.09 KB
/
Copy pathMDXContainer.js
File metadata and controls
153 lines (148 loc) · 4.09 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import {
ExternalLink,
Link,
MDXLink,
MDX,
MarkdownContainer,
Tabs,
SideBySide,
Side,
} from '@newrelic/gatsby-theme-newrelic';
import { css } from '@emotion/react';
import cx from 'classnames';
import { DocTile, DocTiles } from './DocTile';
import DeveloperIcons from './DeveloperIcons';
import EolPage from './EolPage';
import FunctionDefinition from './FunctionDefinition';
import HeaderLink from './HeaderLink';
import LandingPageHero from './LandingPageHero';
import LandingPageTile from './LandingPageTile';
import LandingPageTileGrid from './LandingPageTileGrid';
import InlineSignup from './InlineSignup';
import InlinePopover from './InlinePopover';
import InstallFeedback from './InstallFeedback';
import MDXButton from './MDXButton';
import MDXButtonGroup from './MDXButtonGroup';
import ContributorNote from './ContributorNote';
import MDXTechTileGrid from './MDXTechTileGrid';
import OptionReference from './OptionReference';
import PropTypes from 'prop-types';
import React from 'react';
import TechTile from './TechTile';
import UserJourneyControls from './UserJourneyControls';
import WhatsNextTile from './WhatsNextTile';
import TypeDefReference from './TypeDefReference';
const defaultComponents = {
a: (props) => <MDXLink {...props} displayExternalIcon />,
img: (props) =>
props.style || props.variant === 'TechTile' ? (
<img
width={props.width ? props.width : 'inherit'}
src={props.src}
// this prevents images from stretching when the width is set to a percent value
className={cx(props.className, props.width && 'unbound')}
alt={props.alt ? props.alt : 'Docs site'}
title={props.title}
style={
props.style
? { ...props.style, margin: '0 0.25rem' }
: { margin: '0 0.25rem' }
}
/>
) : (
<span
style={{
position: 'relative',
display: 'block',
textAlign: 'center',
margin: '1em 0',
}}
>
<a
href={props.src}
target="_blank"
rel="noreferrer"
style={{ display: 'inline-block' }}
>
<img
width={props.width ? props.width : 'auto'}
src={props.src}
alt={props.alt ? props.alt : 'Docs site'}
title={props.title}
style={
props.style
? {
...props.style,
borderRadius: '0.25rem',
maxWidth: '100%',
margin: '0 0.25rem',
}
: {
borderRadius: '0.25rem',
maxWidth: '100%',
margin: '0 0.25rem',
}
}
loading="lazy"
/>
</a>
</span>
),
DocTile: (props) => (
<DocTile
css={css`
margin: 1rem 0;
`}
{...props}
>
{props.children}
</DocTile>
),
DocTiles,
ExternalLink: (props) => (
<ExternalLink {...props} onClick={(e) => e.stopPropagation()} />
),
FunctionDefinition,
HeaderLink,
HeroContent: ({ children }) => <>{children}</>,
LandingPageHero,
LandingPageTile,
LandingPageTileGrid,
OptionReference,
TechTile,
TechTileGrid: MDXTechTileGrid,
Button: MDXButton,
ButtonLink: (props) => <MDXButton as={Link} {...props} />,
ButtonGroup: MDXButtonGroup,
DNT: ({ children }) => <>{children}</>, // DoNotTranslate component
CONTRIBUTOR_NOTE: ContributorNote,
Tabs: Tabs,
TabsBar: Tabs.Bar,
TabsBarItem: Tabs.BarItem,
TabsPageItem: Tabs.Page,
TabsPages: Tabs.Pages,
TypeDefReference,
InlineSignup,
InlinePopover,
InstallFeedback,
WhatsNextTile,
Side,
SideBySide,
UserJourneyControls,
EolPage,
DeveloperIcons,
};
const MDXContainer = ({ body, children, components }) => {
return (
<MarkdownContainer>
<MDX body={body} components={{ ...defaultComponents, ...components }} />
{children}
</MarkdownContainer>
);
};
MDXContainer.propTypes = {
body: PropTypes.node,
components: PropTypes.object,
children: PropTypes.node,
};
export default MDXContainer;