Skip to content

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

Change global example code replacement to start and ends with replacement

Nick Rayburn5baa37239be0
diff --git a/apps/docs/components/reference/RefFunctionSection.tsx b/apps/docs/components/reference/RefFunctionSection.tsx
index 23b50392b5e..913d741929d 100644
--- a/apps/docs/components/reference/RefFunctionSection.tsx
+++ b/apps/docs/components/reference/RefFunctionSection.tsx
@@ -114,7 +114,13 @@ const RefFunctionSection: React.FC<IRefFunctionSection> = (props) => {
>
{item.examples &&
item.examples.map((example, exampleIndex) => {
- const exampleString = ''
+ const exampleString =
+ '' +
+ (example.code &&
+ example.code
+ .trim()
+ .replace(/^```(js|ts|dart|c#|kotlin)/, '')
+ .replace(/```$/, ''))
const codeBlockLang = example?.code?.startsWith('```js')
? 'js'
@@ -133,7 +139,6 @@ const RefFunctionSection: React.FC<IRefFunctionSection> = (props) => {
// // Create a single supabase client for interacting with your database
// const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')
// `
- const currentExampleId = example.id
const staticExample = item.examples[exampleIndex]
const response = staticExample.response
@@ -152,15 +157,7 @@ const RefFunctionSection: React.FC<IRefFunctionSection> = (props) => {
language={codeBlockLang}
hideLineNumbers={true}
>
- {exampleString +
- (example.code &&
- example.code
- .replace(/```/g, '')
- .replace('js', '')
- .replace('ts', '')
- .replace('dart', '')
- .replace('c#', '')
- .replace('kotlin', ''))}
+ {exampleString}
</CodeBlock>
{((tables && tables.length > 0) || sql) && (