inline code styles
This commit is contained in:
parent
71ce846b9e
commit
649918abe5
|
@ -1,7 +1,8 @@
|
||||||
import { Heading, Link, Stack, Text } from '@chakra-ui/react';
|
import { Heading, Link, Stack, Text } from '@chakra-ui/react';
|
||||||
import NextLink from 'next/link';
|
import NextLink from 'next/link';
|
||||||
import { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter';
|
import { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter';
|
||||||
import { nightOwl } from 'react-syntax-highlighter/dist/cjs/styles/prism';
|
|
||||||
|
import { Code } from './UI/docs'
|
||||||
|
|
||||||
import bash from 'react-syntax-highlighter/dist/cjs/languages/prism/bash';
|
import bash from 'react-syntax-highlighter/dist/cjs/languages/prism/bash';
|
||||||
import go from 'react-syntax-highlighter/dist/cjs/languages/prism/go';
|
import go from 'react-syntax-highlighter/dist/cjs/languages/prism/go';
|
||||||
|
@ -26,8 +27,6 @@ SyntaxHighlighter.registerLanguage('sh', sh);
|
||||||
SyntaxHighlighter.registerLanguage('solidity', solidity);
|
SyntaxHighlighter.registerLanguage('solidity', solidity);
|
||||||
SyntaxHighlighter.registerLanguage('swift', swift);
|
SyntaxHighlighter.registerLanguage('swift', swift);
|
||||||
|
|
||||||
import { getProgrammingLanguageName } from '../utils';
|
|
||||||
|
|
||||||
const MDXComponents = {
|
const MDXComponents = {
|
||||||
// paragraphs
|
// paragraphs
|
||||||
p: ({ children }: any) => {
|
p: ({ children }: any) => {
|
||||||
|
@ -87,10 +86,12 @@ const MDXComponents = {
|
||||||
<pre>{children}</pre>
|
<pre>{children}</pre>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
// code
|
// code
|
||||||
// code: (code: any) => {
|
code: (code: any) => {
|
||||||
// const language = getProgrammingLanguageName(code);
|
return (
|
||||||
|
<Code code={code} />
|
||||||
|
)
|
||||||
|
|
||||||
// return !!code.inline ? (
|
// return !!code.inline ? (
|
||||||
// <Text
|
// <Text
|
||||||
|
@ -110,7 +111,7 @@ const MDXComponents = {
|
||||||
// {code.children[0]}
|
// {code.children[0]}
|
||||||
// </Stack>
|
// </Stack>
|
||||||
// );
|
// );
|
||||||
// }
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MDXComponents;
|
export default MDXComponents;
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
// Libraries
|
||||||
|
import { Code as ChakraCode } from '@chakra-ui/react';
|
||||||
|
import { FC } from 'react';
|
||||||
|
|
||||||
|
// Utils
|
||||||
|
import { getProgrammingLanguageName } from '../../../utils';
|
||||||
|
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
code: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Code: FC<Props> = ({ code }) => {
|
||||||
|
const language = getProgrammingLanguageName(code);
|
||||||
|
|
||||||
|
return (
|
||||||
|
!!code.inline ?
|
||||||
|
(
|
||||||
|
<ChakraCode
|
||||||
|
background='gray.200'
|
||||||
|
fontFamily='"JetBrains Mono", monospace'
|
||||||
|
fontWeight={400}
|
||||||
|
fontSize='md'
|
||||||
|
lineHeight={4}
|
||||||
|
letterSpacing='1%'
|
||||||
|
pb={2}
|
||||||
|
mb={-2}
|
||||||
|
>
|
||||||
|
{code.children[0]}
|
||||||
|
</ChakraCode>
|
||||||
|
)
|
||||||
|
:
|
||||||
|
(
|
||||||
|
<p>test</p>
|
||||||
|
)
|
||||||
|
);
|
||||||
|
};
|
|
@ -0,0 +1 @@
|
||||||
|
export * from './Code';
|
|
@ -1,7 +1,7 @@
|
||||||
// WIP
|
// WIP
|
||||||
export const getProgrammingLanguageName = (code: any) => {
|
export const getProgrammingLanguageName = (code: any) => {
|
||||||
// const hasLanguageNameProperty = Object.keys(code.node.properties).length > 0;
|
// const hasLanguageNameProperty = Object.keys(code.node.properties).length > 0;
|
||||||
console.log({ code });
|
// console.log({ code });
|
||||||
|
|
||||||
// return hasLanguageNameProperty ? code.node.properties.className[0].split('-')[1] : 'bash';
|
// return hasLanguageNameProperty ? code.node.properties.className[0].split('-')[1] : 'bash';
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue