Add an inline block component

This commit is contained in:
Terry Sutton committed 2022-11-18 16:53:28 -03:30
1 parent 776a892ef8
commit 64e48fb238
3 files changed
+15

No files matched your search

@@ -0,0 +1,11 @@
const InlineCodeTag = ({ children }) => {
// If children isn't a string, just return it as is, just in case
if (typeof children !== 'string') return children
// check the length of the string inside the <code> tag
// if it's fewer than 70 characters, add a white-space: pre so it doesn't wrap
const classes = children.length < 70 ? 'short-inline-codeblock' : ''
return <code className={classes}>{children}</code>
}
export default InlineCodeTag
+2
View File
@@ -18,6 +18,7 @@ import { Heading } from './CustomHTMLElements'
import QuickstartIntro from './MDX/quickstart_intro.mdx'
import ProjectSetup from './MDX/project_setup.mdx'
import { Mermaid } from 'mdx-mermaid/lib/Mermaid'
import InlineCodeTag from './CustomHTMLElements/InlineCode'
const components = {
Admonition,
@@ -55,6 +56,7 @@ const components = {
return <CodeBlock {...props} linesToHighlight={linesToHighlight} />
},
mono: (props: any) => <code className="text-sm">{props.children}</code>,
inlineCode: (props: any) => <InlineCodeTag>{props.children}</InlineCodeTag>,
}
export default components
+2
View File
@@ -220,7 +220,9 @@ article p code {
&::after {
display: none !important;
}
}
.short-inline-codeblock {
@media screen and (min-width: 769px) {
white-space: pre !important;
}