From 5baa37239be0a55c053c522d4e97957f3aa6c33d Mon Sep 17 00:00:00 2001 From: Nick Rayburn <52075362+nrayburn-tech@users.noreply.github.com> Date: Tue, 30 May 2023 19:43:12 -0500 Subject: [PATCH 1/2] Change global example code replacement to start and ends with replacement --- .../reference/RefFunctionSection.tsx | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) 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 = (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 = (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 = (props) => { language={codeBlockLang} hideLineNumbers={true} > - {exampleString + - (example.code && - example.code - .replace(/```/g, '') - .replace('js', '') - .replace('ts', '') - .replace('dart', '') - .replace('c#', '') - .replace('kotlin', ''))} + {exampleString} {((tables && tables.length > 0) || sql) && ( From 3991383b164752b4848e88db7f8c9c25fa020080 Mon Sep 17 00:00:00 2001 From: Nick Rayburn <52075362+nrayburn-tech@users.noreply.github.com> Date: Wed, 31 May 2023 20:14:29 -0500 Subject: [PATCH 2/2] Change regex to be more general --- apps/docs/components/reference/RefFunctionSection.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/docs/components/reference/RefFunctionSection.tsx b/apps/docs/components/reference/RefFunctionSection.tsx index 913d741929d..2be99d3e0d7 100644 --- a/apps/docs/components/reference/RefFunctionSection.tsx +++ b/apps/docs/components/reference/RefFunctionSection.tsx @@ -119,7 +119,7 @@ const RefFunctionSection: React.FC = (props) => { (example.code && example.code .trim() - .replace(/^```(js|ts|dart|c#|kotlin)/, '') + .replace(/^```.*/, '') .replace(/```$/, '')) const codeBlockLang = example?.code?.startsWith('```js')