Skip to content

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

Fix examples.mdx under functions

Joshen Lim53cec10e2440
diff --git a/apps/temp-docs/components/FunctionsExamples.tsx b/apps/temp-docs/components/FunctionsExamples.tsx
new file mode 100644
index 00000000000..32b676ecde7
--- /dev/null
+++ b/apps/temp-docs/components/FunctionsExamples.tsx
@@ -0,0 +1,60 @@
+import ButtonCard from 'components/ButtonCard'
+
+const examples = [
+ {
+ name: 'With supabase-js',
+ description: 'Use the Supabase client inside your Edge Function.',
+ href: 'https://github.com/supabase/supabase/blob/master/examples/edge-functions/supabase/functions/select-from-table-with-auth-rls/index.ts',
+ },
+ {
+ name: 'With CORS headers',
+ description: 'Send CORS headers for invoking from the browser.',
+ href: 'https://github.com/supabase/supabase/blob/master/examples/edge-functions/supabase/functions/browser-with-cors/index.ts',
+ },
+ {
+ name: 'React Native with Stripe',
+ description: 'Full example for using Supabase and Stripe, with Expo.',
+ href: 'https://github.com/supabase-community/expo-stripe-payments-with-supabase-functions',
+ },
+ {
+ name: 'Flutter with Stripe',
+ description: 'Full example for using Supabase and Stripe, with Flutter.',
+ href: 'https://github.com/supabase-community/flutter-stripe-payments-with-supabase-functions',
+ },
+ {
+ name: 'Building a RESTful Service API',
+ description:
+ 'Learn how to use HTTP methods and paths to build a RESTful service for managing tasks.',
+ href: 'https://github.com/supabase/supabase/blob/master/examples/edge-functions/supabase/functions/restful-tasks/index.ts',
+ },
+ {
+ name: 'Working with Supabase Storage',
+ description: 'An example on reading a file from Supbase Storage.',
+ href: 'https://github.com/supabase/supabase/blob/master/examples/edge-functions/supabase/functions/read-storage/index.ts',
+ },
+ {
+ name: 'OpenGraph Image Generation',
+ description:
+ 'Generate Open Graph images with Deno and Supabase Edge Functions, no framework needed.',
+ href: 'https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/opengraph',
+ },
+ {
+ name: 'Get User Location',
+ description: `Get user location data from user's IP address.`,
+ href: 'https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/location',
+ },
+]
+
+const FunctionsExamples = () => {
+ return (
+ <div className="grid grid-cols-12 gap-4">
+ {examples.map((x) => (
+ <div className="col-span-6">
+ <ButtonCard to={x.href} title={x.name} description={x.description} />
+ </div>
+ ))}
+ </div>
+ )
+}
+
+export default FunctionsExamples
diff --git a/apps/temp-docs/components/index.tsx b/apps/temp-docs/components/index.tsx
index 08c783a4651..83fd0379efd 100644
--- a/apps/temp-docs/components/index.tsx
+++ b/apps/temp-docs/components/index.tsx
@@ -1,11 +1,16 @@
import { Tabs, Alert } from 'ui'
+// Common components
import Admonition from './Admonition'
import ButtonCard from './ButtonCard'
import CodeBlock from './CodeBlock/CodeBlock'
+
+// Page specific components
import Frameworks from './Frameworks'
import AuthProviders from './AuthProviders'
+import FunctionsExamples from './FunctionsExamples'
+// Other components
import { Heading } from './CustomHTMLElements'
import QuickstartIntro from './MDX/quickstart_intro.mdx'
import ProjectSetup from './MDX/project_setup.mdx'
@@ -16,10 +21,9 @@ const components = {
CodeBlock,
Frameworks,
AuthProviders,
-
+ FunctionsExamples,
QuickstartIntro,
ProjectSetup,
-
Alert: (props: any) => (
<Alert {...props} className="not-prose">
{props.children}
diff --git a/apps/temp-docs/docs/guides/functions/examples.mdx b/apps/temp-docs/docs/guides/functions/examples.mdx
index ee64360a142..609b970d08c 100644
--- a/apps/temp-docs/docs/guides/functions/examples.mdx
+++ b/apps/temp-docs/docs/guides/functions/examples.mdx
@@ -1,69 +1,11 @@
---
id: examples
title: Examples
-description: Useful Supabase Edge Functions Examples.
+description: Useful Supabase Edge Functions Examples
---
-import ButtonCard from '@site/src/components/ButtonCard'
-const examples = [
- {
- name: 'With supabase-js',
- description: 'Use the Supabase client inside your Edge Function.',
- href: 'https://github.com/supabase/supabase/blob/master/examples/edge-functions/supabase/functions/select-from-table-with-auth-rls/index.ts',
- },
- {
- name: 'With CORS headers',
- description: 'Send CORS headers for invoking from the browser.',
- href: 'https://github.com/supabase/supabase/blob/master/examples/edge-functions/supabase/functions/browser-with-cors/index.ts',
- },
- {
- name: 'React Native with Stripe',
- description: 'Full example for using Supabase and Stripe, with Expo.',
- href: 'https://github.com/supabase-community/expo-stripe-payments-with-supabase-functions',
- },
- {
- name: 'Flutter with Stripe',
- description: 'Full example for using Supabase and Stripe, with Flutter.',
- href: 'https://github.com/supabase-community/flutter-stripe-payments-with-supabase-functions',
- },
- {
- name: 'Building a RESTful Service API',
- description:
- 'Learn how to use HTTP methods and paths to build a RESTful service for managing tasks.',
- href: 'https://github.com/supabase/supabase/blob/master/examples/edge-functions/supabase/functions/restful-tasks/index.ts',
- },
- {
- name: 'Working with Supabase Storage',
- description: 'An example on reading a file from Supbase Storage.',
- href: 'https://github.com/supabase/supabase/blob/master/examples/edge-functions/supabase/functions/read-storage/index.ts',
- },
- {
- name: 'OpenGraph Image Generation',
- description:
- 'Generate Open Graph images with Deno and Supabase Edge Functions, no framework needed.',
- href: 'https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/opengraph',
- },
- {
- name: 'Get User Location',
- description: `Get user location data from user's IP address.`,
- href: 'https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/location',
- },
-]
-
You can find a list of useful [Edge Function Examples](https://github.com/supabase/supabase/tree/master/examples/edge-functions) in our GitHub repository.
<div class="container" style={{ padding: 0 }}>
- <div class="row is-multiline">
- {examples.map((x) => (
- <div class="col col--6">
- <ButtonCard
- class="card"
- to={x.href}
- title={x.name}
- description={x.description}
- style={{ height: '100%' }}
- />
- </div>
- ))}
- </div>
+ <FunctionsExamples />
</div>
diff --git a/apps/temp-docs/layouts/Default.tsx b/apps/temp-docs/layouts/Default.tsx
index f10a5c2d889..daa13b69434 100644
--- a/apps/temp-docs/layouts/Default.tsx
+++ b/apps/temp-docs/layouts/Default.tsx
@@ -24,6 +24,9 @@ const Layout: FC<Props> = ({ meta, children, toc, menuItems, currentPage }) => {
}
}, [])
+ const hasTableOfContents =
+ toc !== undefined && toc.json.filter((item) => item.lvl !== 1 && item.lvl <= 3).length > 0
+
return (
<>
<Head>
@@ -44,14 +47,16 @@ const Layout: FC<Props> = ({ meta, children, toc, menuItems, currentPage }) => {
<div className="docs-width grid grid-cols-12 gap-4 justify-between p-4 pb-8 w-full">
<div
className={`${
- meta?.hide_table_of_contents ? 'col-span-10 2xl:col-span-8' : 'col-span-9'
+ meta?.hide_table_of_contents || !hasTableOfContents
+ ? 'col-span-10 2xl:col-span-8'
+ : 'col-span-9'
} py-4 px-8`}
>
<article className="prose dark:prose-dark dark:bg-scale-200 width-full mt-8">
{children}
</article>
</div>
- {toc && !meta?.hide_table_of_contents && (
+ {hasTableOfContents && !meta?.hide_table_of_contents && (
<div className="border-scale-400 dark:bg-scale-200 thin-scrollbar table-of-contents-height overflow-y-auto sticky col-span-3 border-l px-2">
<TableOfContents toc={toc} />
</div>