-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
MdxComponents.js
24 lines (21 loc) · 730 Bytes
/
MdxComponents.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/** @jsx jsx */
import React from 'react';
import { LinkToStacked } from './CustomLinkToStacked';
import { Link } from 'gatsby';
import { jsx } from 'theme-ui';
import Tippy from './Tippy';
const AnchorTag = ({ href, popups = {}, noPopups = false, ...restProps }) => {
if (!href) href = restProps.to;
if (!href.match(/^http/))
return noPopups ? (
<Link {...restProps} to={href} sx={{ variant: 'links.internal' }} />
) : (
<Tippy content={popups[href.replace(/^\//, '')]} placement="right" animation="shift-away">
<LinkToStacked {...restProps} to={href} sx={{ variant: 'links.internal' }} />
</Tippy>
);
return <a {...restProps} href={href} />;
};
export default {
a: AnchorTag,
};