Browse Source

fix: fix breaking change in mdx-remote

feature/transaction-signing-release-2
Thomas Osmonson 4 years ago
parent
commit
da850af770
  1. 22
      package.json
  2. 13
      src/common/data/mdx.ts
  3. 4
      src/components/clarity-ref.tsx
  4. 2
      src/components/cli-reference.tsx
  5. 48
      src/components/common.tsx
  6. 2
      src/components/footer.tsx
  7. 8
      src/components/glossary.tsx
  8. 4
      src/components/home/footer.tsx
  9. 12
      src/components/mdx/components/blockquote.tsx
  10. 178
      src/components/mdx/components/code.tsx
  11. 3
      src/components/mdx/components/heading.tsx
  12. 21
      src/components/mdx/components/link.tsx
  13. 2
      src/components/mdx/image.tsx
  14. 4
      src/components/mdx/md-contents.tsx
  15. 1
      src/components/mdx/overrides.tsx
  16. 2
      src/pages/references/faqs/[slug].tsx
  17. 1128
      yarn.lock

22
package.json

@ -15,19 +15,19 @@
"@mdx-js/loader": "1.6.16", "@mdx-js/loader": "1.6.16",
"@mdx-js/mdx": "^1.6.16", "@mdx-js/mdx": "^1.6.16",
"@mdx-js/react": "^1.6.16", "@mdx-js/react": "^1.6.16",
"@next/mdx": "^9.5.2", "@next/mdx": "^9.5.3",
"@reach/accordion": "^0.11.0", "@reach/accordion": "^0.11.2",
"@reach/tooltip": "^0.11.0", "@reach/tooltip": "^0.11.2",
"@stacks/ui": "^3.0.0-alpha.12", "@stacks/ui": "^3.0.0-alpha.16",
"@stacks/ui-core": "^1.0.0-beta.6", "@stacks/ui-core": "^1.0.0-beta.6",
"@styled-system/theme-get": "^5.1.2", "@styled-system/theme-get": "^5.1.2",
"@types/mdx-js__react": "^1.5.2", "@types/mdx-js__react": "^1.5.2",
"@types/node": "^14.6.2", "@types/node": "^14.6.4",
"@types/nprogress": "^0.2.0", "@types/nprogress": "^0.2.0",
"@types/reach__tooltip": "^0.2.0", "@types/reach__tooltip": "^0.2.0",
"algoliasearch": "^4.4.0", "algoliasearch": "^4.4.0",
"babel-plugin-macros": "^2.8.0", "babel-plugin-macros": "^2.8.0",
"cache-manager": "^3.3.0", "cache-manager": "^3.4.0",
"cache-manager-fs-hash": "^0.0.9", "cache-manager-fs-hash": "^0.0.9",
"capsize": "^1.1.0", "capsize": "^1.1.0",
"csstype": "^3.0.3", "csstype": "^3.0.3",
@ -42,12 +42,12 @@
"gray-matter": "^4.0.2", "gray-matter": "^4.0.2",
"hast-util-to-string": "^1.0.4", "hast-util-to-string": "^1.0.4",
"html-react-parser": "^0.13.0", "html-react-parser": "^0.13.0",
"image-size": "^0.8.3", "image-size": "^0.9.1",
"lodash.debounce": "^4.0.8", "lodash.debounce": "^4.0.8",
"mdi-react": "7.3.0", "mdi-react": "7.3.0",
"micro-memoize": "^4.0.9", "micro-memoize": "^4.0.9",
"modern-normalize": "^1.0.0", "modern-normalize": "^1.0.0",
"next": "^9.5.2", "next": "^9.5.3",
"next-fonts": "^1.4.0", "next-fonts": "^1.4.0",
"next-mdx-remote": "^1.0.0", "next-mdx-remote": "^1.0.0",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
@ -77,7 +77,7 @@
"remark-vscode": "^1.0.0-beta.2", "remark-vscode": "^1.0.0-beta.2",
"strip-markdown": "^3.1.2", "strip-markdown": "^3.1.2",
"stylis": "^4.0.2", "stylis": "^4.0.2",
"swr": "^0.3.1", "swr": "^0.3.2",
"turndown": "^6.0.0", "turndown": "^6.0.0",
"typescript": "^4.0.2", "typescript": "^4.0.2",
"unified-vscode": "^1.0.0-beta.2", "unified-vscode": "^1.0.0-beta.2",
@ -93,11 +93,11 @@
"@babel/preset-react": "^7.10.4", "@babel/preset-react": "^7.10.4",
"@blockstack/eslint-config": "^1.0.5", "@blockstack/eslint-config": "^1.0.5",
"@blockstack/prettier-config": "^0.0.6", "@blockstack/prettier-config": "^0.0.6",
"@next/bundle-analyzer": "^9.5.2", "@next/bundle-analyzer": "^9.5.3",
"@typescript-eslint/eslint-plugin": "^4.0.1", "@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1", "@typescript-eslint/parser": "^4.0.1",
"babel-plugin-styled-components": "^1.11.0", "babel-plugin-styled-components": "^1.11.0",
"eslint": "^7.8.0", "eslint": "^7.8.1",
"eslint-plugin-import": "^2.22.0", "eslint-plugin-import": "^2.22.0",
"eslint-plugin-prettier": "^3.1.4", "eslint-plugin-prettier": "^3.1.4",
"husky": "^4.2.5", "husky": "^4.2.5",

13
src/common/data/mdx.ts

@ -9,10 +9,15 @@ const { rehypePlugins } = require('../../../lib/rehype-plugins');
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
export const wrapValueInTicks = value => '`' + value.replace('`', '').replace('`', '') + '`'; export const wrapValueInTicks = value => '`' + value.replace('`', '').replace('`', '') + '`';
const mdxOptions = {
remarkPlugins,
rehypePlugins,
};
const renderToStringOptions = { components: Components, mdxOptions };
export const convertRemoteDataToMDX = async (arr: any[], key: string) => export const convertRemoteDataToMDX = async (arr: any[], key: string) =>
Promise.all( Promise.all(arr.map(entry => renderToString(entry[key], renderToStringOptions)));
arr.map(entry => renderToString(entry[key], Components, { remarkPlugins, rehypePlugins }))
);
export const renderMdx = async (content: string): Promise<any> => export const renderMdx = async (content: string): Promise<any> =>
renderToString(content, Components, { remarkPlugins, rehypePlugins }) as Promise<any>; renderToString(content, renderToStringOptions) as Promise<any>;

4
src/components/clarity-ref.tsx

@ -8,7 +8,7 @@ export const ClarityKeywordReference = React.memo(({ content, headings }: any) =
return ( return (
<> <>
<TableOfContents mb={space('extra-loose')} label="Contents" headings={headings} /> <TableOfContents mb={space('extra-loose')} label="Contents" headings={headings} />
{hydrate(content, Components)} {hydrate(content, { components: Components })}
</> </>
); );
}); });
@ -21,7 +21,7 @@ export const ClarityFunctionReference = React.memo(({ content, headings }: any)
label="Contents" label="Contents"
headings={headings} headings={headings}
/> />
{hydrate(content, Components)} {hydrate(content, { components: Components })}
</> </>
); );
}); });

2
src/components/cli-reference.tsx

@ -34,6 +34,7 @@ const ReferenceEntry = ({ entry, usage }) => (
</Components.p> </Components.p>
{hydrate(usage, { {hydrate(usage, {
components: {
...Components, ...Components,
p: (props: any) => ( p: (props: any) => (
<Components.p <Components.p
@ -41,6 +42,7 @@ const ReferenceEntry = ({ entry, usage }) => (
style={{ display: 'block', wordBreak: 'break-word', hyphens: 'auto' }} style={{ display: 'block', wordBreak: 'break-word', hyphens: 'auto' }}
/> />
), ),
},
})} })}
<Components.h3 id={`${slugify(entry.command)}-arguments`}>Arguments</Components.h3> <Components.h3 id={`${slugify(entry.command)}-arguments`}>Arguments</Components.h3>
<Grid <Grid

48
src/components/common.tsx

@ -0,0 +1,48 @@
import React from 'react';
import {
Box,
Grid,
Flex,
BoxProps,
transition,
space,
GridProps,
color,
FlexProps,
} from '@stacks/ui';
import { CONTENT_MAX_WIDTH } from '@common/constants';
export const CircleIcon: React.FC<
FlexProps & { icon: React.FC<any>; hover?: boolean; dark?: boolean }
> = ({ size = '72px', icon: Icon, hover, dark, ...rest }) => (
<Flex
size={size}
alignItems="center"
justify="center"
borderRadius={size}
bg={color(hover ? 'accent' : 'bg-alt')}
transition={transition}
{...rest}
>
<Box size="34px" color={color(hover ? 'bg' : 'invert')}>
<Icon transition={transition} />
</Box>
</Flex>
);
export const Section: React.FC<GridProps> = props => (
<Grid style={{ placeItems: 'center' }} py="64px" position="relative" width="100%" {...props} />
);
export const SectionWrapper: React.FC<BoxProps> = props => (
<Box
mx="auto"
zIndex={99}
position="relative"
width="100%"
maxWidth={`${CONTENT_MAX_WIDTH}px`}
overflow="hidden"
pt={space('extra-loose')}
{...props}
/>
);

2
src/components/footer.tsx

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { space } from '@stacks/ui'; import { space } from '@stacks/ui';
import { Pagination } from '@components/pagination'; import { Pagination } from '@components/pagination';
import { Section, SectionWrapper } from '@components/home/common'; import { Section, SectionWrapper } from '@components/common';
import { FeedbackSection } from '@components/feedback'; import { FeedbackSection } from '@components/feedback';
const Footer = ({ hidePagination, ...rest }: any) => { const Footer = ({ hidePagination, ...rest }: any) => {

8
src/components/glossary.tsx

@ -3,7 +3,7 @@ import { Box, space } from '@stacks/ui';
import hydrate from 'next-mdx-remote/hydrate'; import hydrate from 'next-mdx-remote/hydrate';
import { Components } from '@components/mdx/mdx-components'; import { Components } from '@components/mdx/mdx-components';
import { slugify } from '@common/utils'; import { slugify } from '@common/utils';
import { css } from '@stacks/ui-core'; import { css, Theme } from '@stacks/ui-core';
import { TableOfContents } from '@components/toc'; import { TableOfContents } from '@components/toc';
export const Glossary = ({ data }) => { export const Glossary = ({ data }) => {
@ -24,7 +24,7 @@ export const Glossary = ({ data }) => {
<Box <Box
{...{ width: '100%', maxWidth: '48ch', pl: space(['none', 'none', 'base-loose']) }} {...{ width: '100%', maxWidth: '48ch', pl: space(['none', 'none', 'base-loose']) }}
css={theme => css={(theme: Theme) =>
css({ css({
'& p': { '& p': {
display: 'block', display: 'block',
@ -37,7 +37,9 @@ export const Glossary = ({ data }) => {
})(theme) })(theme)
} }
> >
{hydrate(entry.definition, Components)} {hydrate(entry.definition, {
components: Components,
})}
</Box> </Box>
</> </>
))} ))}

4
src/components/home/footer.tsx

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { Box, BoxProps, Grid, space, themeColor } from '@stacks/ui'; import { Box, BoxProps, Grid, space, themeColor } from '@stacks/ui';
import { Section, SectionWrapper } from '@components/home/common'; import { Section, SectionWrapper } from '@components/common';
import { Text } from '@components/typography'; import { Text } from '@components/typography';
const SectionHeading: React.FC<BoxProps> = props => ( const SectionHeading: React.FC<BoxProps> = props => (
@ -9,7 +9,7 @@ const SectionHeading: React.FC<BoxProps> = props => (
); );
const SectionItem: React.FC<BoxProps> = props => ( const SectionItem: React.FC<BoxProps> = props => (
<Text mb={space('tight')} display="block" color={themeColor('ink.300')} {...props} /> <Text mb={space('tight')} display="block" color={themeColor('ink.300') as any} {...props} />
); );
export const Footer: React.FC<BoxProps> = props => ( export const Footer: React.FC<BoxProps> = props => (

12
src/components/mdx/components/blockquote.tsx

@ -2,7 +2,7 @@ import { Box, Flex, BoxProps, color, themeColor, space } from '@stacks/ui';
import React from 'react'; import React from 'react';
import { border } from '@common/utils'; import { border } from '@common/utils';
import { css } from '@stacks/ui-core'; import { css, Theme } from '@stacks/ui-core';
import { CheckCircleIcon } from '@components/icons/check-circle'; import { CheckCircleIcon } from '@components/icons/check-circle';
import { AlertTriangleIcon } from '@components/icons/alert-triangle'; import { AlertTriangleIcon } from '@components/icons/alert-triangle';
import { AlertCircleIcon } from '@components/icons/alert-circle'; import { AlertCircleIcon } from '@components/icons/alert-circle';
@ -79,7 +79,7 @@ export const Blockquote: React.FC<BoxProps> = React.memo(
py: space('base'), py: space('base'),
px: space('base'), px: space('base'),
}} }}
css={theme => css={(theme: Theme) =>
css({ css({
'& p': { '& p': {
flexGrow: 1, flexGrow: 1,
@ -90,7 +90,13 @@ export const Blockquote: React.FC<BoxProps> = React.memo(
{...styles} {...styles}
> >
{Icon && ( {Icon && (
<Flex alignItems="center" height="28x" flexShrink={0} color={accent} width="22px"> <Flex
alignItems="center"
height="28x"
flexShrink={0}
color={accent as any}
width="22px"
>
<Box position="absolute" top="16px" size="22px"> <Box position="absolute" top="16px" size="22px">
<Icon /> <Icon />
</Box> </Box>

178
src/components/mdx/components/code.tsx

@ -1,9 +1,20 @@
/** @jsx jsx */
import React, { Children } from 'react'; import React, { Children } from 'react';
import {
import { Box, Flex, BoxProps, color, space, useClipboard, themeColor } from '@stacks/ui'; Box,
Flex,
BoxProps,
Fade,
color,
space,
useClipboard,
themeColor,
FlexProps,
} from '@stacks/ui';
import { ClipboardCheckIcon } from '@components/icons/clipboard-check'; import { ClipboardCheckIcon } from '@components/icons/clipboard-check';
import { border, onlyText } from '@common/utils'; import { border, onlyText } from '@common/utils';
import { css } from '@stacks/ui-core'; import { css, ForwardRefExoticComponentWithAs, forwardRefWithAs, Theme } from '@stacks/ui-core';
import { jsx } from '@emotion/react';
import { Text } from '@components/typography'; import { Text } from '@components/typography';
import { useHover } from 'use-events'; import { useHover } from 'use-events';
import { IconButton } from '@components/icon-button'; import { IconButton } from '@components/icon-button';
@ -39,63 +50,85 @@ const generateCssStylesForHighlightedLines = (numbers: number[] = []) => {
return record; return record;
}; };
const CodeCopyButton: React.FC<
{ onCopy?: () => void; lines?: number; hasCopied?: boolean; styles?: any } & FlexProps
> = ({ onCopy, lines, hasCopied, styles, ...props }) => {
const CopyIcon = hasCopied ? ClipboardCheckIcon : BaseCopyIcon;
return (
<Flex
size="56px"
justifyContent="flex-end"
alignItems="flex-start"
position="absolute"
right="0"
top="0"
zIndex={999999}
px={space('base')}
py={lines === 1 ? '10px' : space('base')}
display={['none', 'none', 'flex']}
pointerEvents="none"
style={styles}
{...(props as any)}
>
<IconButton
title="Copy to clipboard"
bg="ink.900"
_hover={{
color: 'white',
// @ts-ignore
bg: themeColor('ink.900'),
}}
color={themeColor('ink.400') as any}
onClick={onCopy}
size="35px"
p="0"
display="grid"
placeItems="center"
style={{
pointerEvents: 'all',
}}
>
<CopyIcon size="20px" />
</IconButton>
</Flex>
);
};
export const Code: React.FC< export const Code: React.FC<
BoxProps & { highlight?: string; lang?: string; lines: number } BoxProps & { highlight?: string; lang?: string; lines: number }
> = React.memo( > = React.memo(
React.forwardRef(({ children, highlight, lang, lines, ...rest }, ref) => { React.forwardRef(({ children, highlight, lang, lines, ...rest }, ref) => {
const [hover, bind] = useHover(); const [hover, bind] = useHover();
const numbers = getHighlightLineNumbers(highlight); const numbers = getHighlightLineNumbers(highlight);
const convertSingleChildToString = child => onlyText(child).replace(/\n/g, ''); const convertSingleChildToString = child => onlyText(child).replace(/\n/g, '');
const tokenLines = Children.toArray(children).map(convertSingleChildToString); const tokenLines = Children.toArray(children).map(convertSingleChildToString);
const codeString = tokenLines.join('\n').replace(/\n\n\n/g, '\n\n'); const codeString = tokenLines.join('\n').replace(/\n\n\n/g, '\n\n');
const { hasCopied, onCopy } = useClipboard(codeString); const { hasCopied, onCopy } = useClipboard(codeString);
const hasLineNumbers = lines > LINE_MINIMUM && lang !== 'bash';
const CopyIcon = hasCopied ? ClipboardCheckIcon : BaseCopyIcon;
return ( return (
<Box overflow="hidden" position="relative" {...bind}>
<Box <Box
className={lines <= 3 ? 'no-line-numbers' : ''} overflow="hidden"
position="relative" position="relative"
ref={ref as any} css={(theme: Theme) =>
overflowX="auto" css({
>
<Box
as="code"
{...{
width: '100%',
display: 'flex',
flexDirection: 'column',
minWidth: 'fit-content',
counterReset: 'line',
pr: space(['base-loose', 'base-loose', 'extra-loose', 'extra-loose']),
pl:
lines <= LINE_MINIMUM || lang === 'bash'
? space(['extra-loose', 'extra-loose', 'base-loose', 'base-loose'])
: 'unset',
}}
css={css({
'.token-line': { '.token-line': {
display: 'inline-block', counterIncrement: 'line',
...generateCssStylesForHighlightedLines(numbers),
},
'& .token-line': {
'&__empty': { '&__empty': {
height: '24px', height: '24px',
}, },
'.comment': { '.comment': {
color: 'rgba(255,255,255,0.5) !important', color: 'rgba(255,255,255,0.5) !important',
}, },
...generateCssStylesForHighlightedLines(numbers),
display: 'flex', display: 'flex',
fontSize: '14px', fontSize: '14px',
'&::before': pl: !hasLineNumbers
lines > LINE_MINIMUM && lang !== 'bash' ? space(['extra-loose', 'extra-loose', '20px', '20px'])
: undefined,
'&:before': hasLineNumbers
? { ? {
counterIncrement: 'line', flexShrink: 0,
content: 'counter(line, decimal-leading-zero)', content: 'counter(line, decimal-leading-zero)',
display: 'grid', display: 'grid',
placeItems: 'center', placeItems: 'center',
@ -108,15 +141,24 @@ export const Code: React.FC<
} }
: {}, : {},
}, },
})} })(theme)
{...rest} }
{...bind}
>
<Box
className={lines <= 3 ? 'no-line-numbers' : ''}
position="relative"
ref={ref as any}
overflowX="auto"
> >
<Box as="code" {...(rest as any)}>
<Box height="16px" width="100%" /> <Box height="16px" width="100%" />
<Box <Box
as="span" as="span"
position="absolute" position="absolute"
color="transparent" color="transparent"
top="16px" top="16px"
pr={space(['extra-loose', 'extra-loose', '20px', '20px'])}
left={ left={
lines <= LINE_MINIMUM || lang === 'bash' lines <= LINE_MINIMUM || lang === 'bash'
? space(['extra-loose', 'extra-loose', '20px', '20px']) ? space(['extra-loose', 'extra-loose', '20px', '20px'])
@ -132,46 +174,19 @@ export const Code: React.FC<
userSelect: 'none', userSelect: 'none',
pointerEvents: 'none', pointerEvents: 'none',
}} }}
display="flex"
flexDirection="column"
> >
{children} {children}
</Box> </Box>
<Box height="16px" width="100%" /> <Box height="16px" width="100%" />
</Box> </Box>
</Box> </Box>
{hover ? ( <Fade in={hover}>
<Flex {styles => (
size="80%" <CodeCopyButton styles={styles} hasCopied={hasCopied} lines={lines} onCopy={onCopy} />
justifyContent="flex-end" )}
alignItems="flex-start" </Fade>
position="absolute"
right="0"
top="0"
zIndex={999999}
px={space('base')}
py={lines === 1 ? '10px' : space('base')}
display={['none', 'none', 'flex']}
style={{
pointerEvents: 'none',
}}
>
<IconButton
title="Copy to clipboard"
bg="ink.900"
_hover={{
color: 'white',
// @ts-ignore
bg: themeColor('ink.900'),
}}
color={themeColor('ink.400')}
onClick={onCopy}
style={{
pointerEvents: 'all',
}}
>
<CopyIcon size="20px" />
</IconButton>
</Flex>
) : null}
</Box> </Box>
); );
}) })
@ -185,18 +200,15 @@ const preProps = {
padding: '2px 6px', padding: '2px 6px',
boxShadow: '0 1px 2px rgba(0, 0, 0, 0.04)', boxShadow: '0 1px 2px rgba(0, 0, 0, 0.04)',
bg: color('bg'), bg: color('bg'),
};
export const InlineCode: React.FC<BoxProps> = ({ children, ...rest }) => (
<Text
as="code"
{...preProps}
{...{
fontSize: '14px', fontSize: '14px',
lineHeight: '20px', lineHeight: '20px',
}} };
{...rest}
> export const InlineCode: ForwardRefExoticComponentWithAs<BoxProps, 'code'> = forwardRefWithAs<
BoxProps,
'code'
>(({ as = 'code', children, ...rest }, ref) => (
<Text ref={ref} as={as} {...(preProps as any)} {...(rest as any)}>
{children} {children}
</Text> </Text>
); ));

3
src/components/mdx/components/heading.tsx

@ -78,7 +78,7 @@ export const Heading: ForwardRefExoticComponentWithAs<
FlexProps, FlexProps,
'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
> = forwardRefWithAs<FlexProps, 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'>( > = forwardRefWithAs<FlexProps, 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'>(
({ as, children, id, ...rest }) => { ({ as, children, id, ...rest }, ref) => {
const { isActive, doChangeActiveSlug } = useActiveHeading(id); const { isActive, doChangeActiveSlug } = useActiveHeading(id);
const { bind: _bind, hover, active } = useTouchable(); const { bind: _bind, hover, active } = useTouchable();
@ -108,6 +108,7 @@ export const Heading: ForwardRefExoticComponentWithAs<
justifyContent: 'flex-start', justifyContent: 'flex-start',
cursor: id && hover ? 'pointer' : 'unset', cursor: id && hover ? 'pointer' : 'unset',
}} }}
ref={ref}
{...rest} {...rest}
> >
<Box as="span">{children}</Box> <Box as="span">{children}</Box>

21
src/components/mdx/components/link.tsx

@ -5,7 +5,7 @@ import { useAppState } from '@common/hooks/use-app-state';
import { border, transition } from '@common/utils'; import { border, transition } from '@common/utils';
import { Text } from '@components/typography'; import { Text } from '@components/typography';
import { useTouchable } from '@common/hooks/use-touchable'; import { useTouchable } from '@common/hooks/use-touchable';
import { css, forwardRefWithAs } from '@stacks/ui-core'; import { ForwardRefExoticComponentWithAs, forwardRefWithAs } from '@stacks/ui-core';
import { getHeadingStyles } from '@components/mdx/typography'; import { getHeadingStyles } from '@components/mdx/typography';
import { PageMeta } from '@components/page-meta'; import { PageMeta } from '@components/page-meta';
@ -22,9 +22,12 @@ export const MarkdownLink = ({ href, ...rest }: { href: string }) => {
); );
}; };
export const SmartLink = ({ href, ...rest }: { href: string }) => { export const SmartLink: ForwardRefExoticComponentWithAs<{ href?: string }, 'a'> = forwardRefWithAs<
{ href?: string },
'a'
>(({ href, ...rest }, ref) => {
const isExternal = !href || href?.includes('http') || href?.includes('mailto'); const isExternal = !href || href?.includes('http') || href?.includes('mailto');
const link = <Link href={href || undefined} {...rest} />; const link = <Link ref={ref} href={href || undefined} {...rest} />;
return isExternal ? ( return isExternal ? (
link link
@ -33,7 +36,7 @@ export const SmartLink = ({ href, ...rest }: { href: string }) => {
{link} {link}
</NextLink> </NextLink>
); );
}; });
const Card = ({ route, styles, ...rest }) => { const Card = ({ route, styles, ...rest }) => {
const { description } = route; const { description } = route;
@ -120,10 +123,10 @@ export const LinkWithHover = forwardRef(
} }
); );
export const Link = forwardRefWithAs<BoxProps, 'a'>((props, ref) => { export const Link: ForwardRefExoticComponentWithAs<BoxProps, 'a'> = forwardRefWithAs<BoxProps, 'a'>(
return ( ({ as = 'a', ...props }, ref) => (
<Box <Box
as={props.href ? 'a' : 'span'} as={props.href ? as : 'span'}
ref={ref} ref={ref}
color="var(--colors-accent)" color="var(--colors-accent)"
cursor="pointer" cursor="pointer"
@ -133,5 +136,5 @@ export const Link = forwardRefWithAs<BoxProps, 'a'>((props, ref) => {
rel="nofollow noopener noreferrer" rel="nofollow noopener noreferrer"
{...props} {...props}
/> />
); )
}); );

2
src/components/mdx/image.tsx

@ -95,7 +95,7 @@ export const Img: ForwardRefExoticComponentWithAs<
// (because of the built in lazy-loading) // (because of the built in lazy-loading)
const aspectRatio = getAspectRatio(dimensions); const aspectRatio = getAspectRatio(dimensions);
const width = dimensions.width <= 720 ? dimensions.width : '100%'; const width = dimensions.width <= 720 ? `${dimensions.width}px` : '100%';
return ( return (
<Box width={width} maxWidth="100%" padding="0 !important" position="relative" className="img"> <Box width={width} maxWidth="100%" padding="0 !important" position="relative" className="img">
<Box height="0" paddingBottom={`${aspectRatio}%`} width="100%" /> <Box height="0" paddingBottom={`${aspectRatio}%`} width="100%" />

4
src/components/mdx/md-contents.tsx

@ -10,7 +10,7 @@ import { border } from '@common/utils';
import { getCapsizeStyles } from '@components/mdx/typography'; import { getCapsizeStyles } from '@components/mdx/typography';
import { MDXProvider } from '@mdx-js/react'; import { MDXProvider } from '@mdx-js/react';
import { MDXComponents } from '@components/mdx'; import { MDXComponents } from '@components/mdx';
import { css, ThemeUICSSObject } from '@stacks/ui-core'; import { css, Theme, ThemeUICSSObject } from '@stacks/ui-core';
export const styleOverwrites: ThemeUICSSObject = { export const styleOverwrites: ThemeUICSSObject = {
'& > section': { '& > section': {
'&:nth-child(2)': { '&:nth-child(2)': {
@ -253,7 +253,7 @@ export const MDContents: React.FC<any> = ({ pageTop: PageTop = null, headings, c
width={['100%', '100%', '100%', `calc(100% - ${isHome ? 0 : TOC_WIDTH}px)`]} width={['100%', '100%', '100%', `calc(100% - ${isHome ? 0 : TOC_WIDTH}px)`]}
mx="0" mx="0"
pt="0" pt="0"
css={theme => css(styleOverwrites)(theme)} css={(theme: Theme) => css(styleOverwrites)(theme)}
pr={!isHome && ['0', '0', '0', 'extra-loose']} pr={!isHome && ['0', '0', '0', 'extra-loose']}
> >
{PageTop && <PageTop />} {PageTop && <PageTop />}

1
src/components/mdx/overrides.tsx

@ -33,6 +33,7 @@ const GlobalStyles = (
body { body {
font-family: 'Soehne', Inter, sans-serif; font-family: 'Soehne', Inter, sans-serif;
} }
@counter-style list { @counter-style list {
pad: '0'; pad: '0';
} }

2
src/pages/references/faqs/[slug].tsx

@ -47,7 +47,7 @@ const FAQItem = React.memo(({ faq, ...rest }: any) => {
</Box> </Box>
</Flex> </Flex>
<Box pb={space('extra-loose')} as={AccordionPanel}> <Box pb={space('extra-loose')} as={AccordionPanel}>
{hydrate(faq.body, Components)} {hydrate(faq.body, { components: Components })}
</Box> </Box>
</Box> </Box>
</Components.section> </Components.section>

1128
yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save