Custom handle inline code blocks

This commit is contained in:
Terry Sutton committed 2022-11-21 09:35:55 -03:30
1 parent 099706260e
commit 502f07a8cf
4 files changed
+28 -1

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
const InlineCodeTag = ({ children }: any) => {
// 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
@@ -4,6 +4,7 @@ import CodeBlock from '~/components/CodeBlock/CodeBlock'
import ImageGrid from '~/components/ImageGrid'
import Quote from '~/components/Quote'
import Chart from '~/components/Charts/PGCharts'
import InlineCodeTag from '~/components/InlineCode'
// import all components used in blog articles here
// to do: move this into a helper/utils, it is used elsewhere
@@ -47,6 +48,7 @@ export default function mdxComponents(type?: 'blog' | 'lp' | undefined) {
}
return <img {...props} />
},
code: (props: any) => <InlineCodeTag>{props.children}</InlineCodeTag>,
}
return components
+8 -1
View File
@@ -5,9 +5,16 @@
<link>https://supabase.com</link>
<description>Latest news from Supabase</description>
<language>en</language>
<lastBuildDate>Mon, 07 Nov 2022 03:03:30 +0000</lastBuildDate>
<lastBuildDate>Wed, 16 Nov 2022 03:03:30 +0000</lastBuildDate>
<atom:link href="https://supabase.com/rss.xml" rel="self" type="application/rss+xml"/>
<item>
<guid>https://supabase.com/blog/fetching-and-caching-supabase-data-in-next-js-server-components</guid>
<title>Fetching and caching Supabase data in Next.js 13 Server Components</title>
<link>https://supabase.com/blog/fetching-and-caching-supabase-data-in-next-js-server-components</link>
<description>Next.js 13 introduces new data fetching and caching methods to enable React Server Components and Suspense.</description>
<pubDate>Wed, 16 Nov 2022 03:03:30 +0000</pubDate>
</item>
<item>
<guid>https://supabase.com/blog/authentication-in-ionic-angular</guid>
<title>Authentication in Ionic Angular with Supabase</title>
<link>https://supabase.com/blog/authentication-in-ionic-angular</link>
+7
View File
@@ -421,3 +421,10 @@ launch week
.recharts-surface {
overflow: visible;
}
/* Fix inline code block wrapping */
@media screen and (min-width: 769px) {
.short-inline-codeblock {
white-space: pre !important;
}
}