Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

added in codeBlockLang variable for code examples

Ollie Halliday748e609e0a5b
diff --git a/apps/docs/components/reference/RefFunctionSection.tsx b/apps/docs/components/reference/RefFunctionSection.tsx
index 8c36b793b8b..d2021223259 100644
--- a/apps/docs/components/reference/RefFunctionSection.tsx
+++ b/apps/docs/components/reference/RefFunctionSection.tsx
@@ -130,6 +130,14 @@ const RefFunctionSection: React.FC<IRefFunctionSection> = (props) => {
{item.examples &&
item.examples.map((example, exampleIndex) => {
const exampleString = ''
+
+ const codeBlockLang = example?.code?.includes('```js')
+ ? 'js'
+ : example?.code?.includes('```ts')
+ ? 'ts'
+ : example?.code?.includes('```dart')
+ ? 'dart'
+ : 'js'
// `
// import { createClient } from '@supabase/supabase-js'
@@ -196,9 +204,10 @@ const RefFunctionSection: React.FC<IRefFunctionSection> = (props) => {
</RefDetailCollapse>
)}
+
<CodeBlock
className="useless-code-block-class"
- language="js"
+ language={codeBlockLang}
hideLineNumbers={true}
>
{exampleString +
@@ -206,7 +215,8 @@ const RefFunctionSection: React.FC<IRefFunctionSection> = (props) => {
example.code
.replace(/```/g, '')
.replace('js', '')
- .replace('ts', ''))}
+ .replace('ts', '')
+ .replace('dart', ''))}
</CodeBlock>
{response && (
@@ -217,7 +227,7 @@ const RefFunctionSection: React.FC<IRefFunctionSection> = (props) => {
>
<CodeBlock
className="useless-code-block-class"
- language="js"
+ language={codeBlockLang}
hideLineNumbers={true}
>
{response.replace(/```/g, '').replace('json', '')}