refactor(website): use mantine code blocks (#8512)

This commit is contained in:
Suneet Tipirneni
2022-08-17 16:38:11 -04:00
committed by GitHub
parent 20680efbc9
commit 0bf3df30da
4 changed files with 38 additions and 23 deletions

View File

@@ -1,9 +1,9 @@
import { Anchor, Box, Text } from '@mantine/core';
import { Anchor, Box, Code, Text } from '@mantine/core';
import { Prism } from '@mantine/prism';
import { DocNodeKind, StandardTags } from '@microsoft/tsdoc';
import Link from 'next/link';
import type { Language } from 'prism-react-renderer';
import type { ReactNode } from 'react';
import { PrismAsyncLight as SyntaxHighlighter } from 'react-syntax-highlighter';
import { vscDarkPlus } from 'react-syntax-highlighter/dist/cjs/styles/prism';
import { BlockComment } from './BlockComment';
import type { DocBlockJSON } from '~/DocModel/comment/CommentBlock';
import type { AnyDocNodeJSON } from '~/DocModel/comment/CommentNode';
@@ -61,24 +61,17 @@ export function TSDoc({ node }: { node: AnyDocNodeJSON }): JSX.Element {
case DocNodeKind.CodeSpan: {
const { code } = node as DocFencedCodeJSON;
return (
<pre key={idx} className="inline">
<Code key={idx} className="inline text-sm font-mono">
{code}
</pre>
</Code>
);
}
case DocNodeKind.FencedCode: {
const { language, code } = node as DocFencedCodeJSON;
return (
<SyntaxHighlighter
key={idx}
wrapLines
wrapLongLines
language={language}
style={vscDarkPlus}
codeTagProps={{ style: { fontFamily: 'JetBrains Mono' } }}
>
<Prism key={idx} language={language as Language} withLineNumbers colorScheme="dark">
{code}
</SyntaxHighlighter>
</Prism>
);
}
case DocNodeKind.Block: {