Skip to content

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

Add preamble files to top of ref

Terry Suttona069fab32b9c
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuGuideList.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuGuideList.tsx
index 659c09ea9ad..cfeeb10c71c 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuGuideList.tsx
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuGuideList.tsx
@@ -14,7 +14,7 @@ const NavigationMenuGuideList = ({ currentLevel, setLevel, id }) => {
const menu = NavItems[id]
- console.log(id, 'url is:', menu.url)
+ //console.log(id, 'url is:', menu.url)
// get url
const url = router.asPath
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx
index 8dbeca1fc9e..20d54b9a05a 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx
@@ -57,14 +57,7 @@ const NavigationMenuRefList = ({ currentLevel, setLevel, id }) => {
const SideMenuTitle = ({ title }: { title: string }) => {
return (
- <span
- className="
- font-mono text-xs uppercase
- text-scale-1200 font-medium
- tracking-wider
- mb-3
- "
- >
+ <span className="font-mono text-xs uppercase text-scale-1200 font-medium tracking-wider mb-3">
{title}
</span>
)
@@ -105,7 +98,7 @@ const NavigationMenuRefList = ({ currentLevel, setLevel, id }) => {
<span>Back to Main Menu</span>
</a>
</Link>
- {console.log(menu)}
+ {/* {console.log(menu)} */}
{/* )} */}
{/* {process.env.NEXT_PUBLIC_EXPERIMENTAL_REF !== 'true' && ( */}
<div className="flex items-center gap-3 my-3">
@@ -123,6 +116,8 @@ const NavigationMenuRefList = ({ currentLevel, setLevel, id }) => {
</div>
{/* )} */}
<ul className="function-link-list">
+ toppy
+ <SideMenuTitle title="Get Started" />
<Divider />
<SideMenuTitle title="Database" />
{/* {console.log({ clientLibsCommon })} */}
@@ -136,10 +131,8 @@ const NavigationMenuRefList = ({ currentLevel, setLevel, id }) => {
</>
)
})}
-
<Divider />
<SideMenuTitle title="Auth" />
-
{clientLibsCommon.functions
.filter((x) => x.product === 'auth')
.map((x, index) => {
diff --git a/apps/docs/docs/ref/js/release-notes.mdx b/apps/docs/docs/ref/js/release-notes.mdx
new file mode 100644
index 00000000000..d14cad6a02e
--- /dev/null
+++ b/apps/docs/docs/ref/js/release-notes.mdx
@@ -0,0 +1,7 @@
+Release notes mdx file
+
+This is a list in markdown:
+
+- One
+- Two
+- Three
diff --git a/apps/docs/docs/ref/js/sign-up.mdx b/apps/docs/docs/ref/js/sign-up.mdx
new file mode 100644
index 00000000000..fbc69e45531
--- /dev/null
+++ b/apps/docs/docs/ref/js/sign-up.mdx
@@ -0,0 +1,9 @@
+My MDX Page with a Layout
+
+This is a list in markdown:
+
+- One
+- Two
+- Three
+
+Checkout my React component:
diff --git a/apps/docs/docs/ref/js/typescript-support.mdx b/apps/docs/docs/ref/js/typescript-support.mdx
new file mode 100644
index 00000000000..ce25122af44
--- /dev/null
+++ b/apps/docs/docs/ref/js/typescript-support.mdx
@@ -0,0 +1,7 @@
+Typescript support file
+
+This is a list in markdown:
+
+- One
+- Two
+- Three
diff --git a/apps/docs/generator/legacy.ts b/apps/docs/generator/legacy.ts
index 416ee41e0ce..ce3edd432f2 100644
--- a/apps/docs/generator/legacy.ts
+++ b/apps/docs/generator/legacy.ts
@@ -41,7 +41,6 @@ export default async function gen(inputFileName: string, outputDir: string) {
try {
// get the slug from common-client-libs.yml
//const slug = slugify(pageSpec.id)
- console.log(pageSpec.id)
const slug = commonDocSpec.functions.find((fn) => fn.id === pageSpec.id).slug
const hasTsRef = pageSpec['$ref'] || null
const tsDefinition = hasTsRef && extractTsDocNode(hasTsRef, definition)
diff --git a/apps/docs/pages/_middleware.ts b/apps/docs/pages/_middleware.ts
deleted file mode 100644
index 8d8ff4a21f7..00000000000
--- a/apps/docs/pages/_middleware.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { NextResponse } from 'next/server'
-import type { NextRequest } from 'next/server'
-import isbot from 'isbot'
-
-// This function can be marked `async` if using `await` inside
-export function middleware(request: NextRequest) {
- const specs = ['javascript', 'dart']
-
- if (isbot(request.headers.get('user-agent'))) {
- console.log('is a bot')
- for (const lib of specs) {
- if (request.url.includes(`reference/${lib}`)) {
- const requestSlug = request.url.split('/').pop()
-
- return NextResponse.rewrite(
- new URL(`/docs/reference/${lib}/crawlers/${requestSlug}`, request.url).toString()
- )
- }
- }
- } else {
- return NextResponse.next()
- }
-}
diff --git a/apps/docs/pages/reference/javascript/[...slug].tsx b/apps/docs/pages/reference/javascript/[...slug].tsx
index f338e234341..43d31fc66d9 100644
--- a/apps/docs/pages/reference/javascript/[...slug].tsx
+++ b/apps/docs/pages/reference/javascript/[...slug].tsx
@@ -62,207 +62,220 @@ export default function JSReference(props) {
}
return (
- <RefSubLayout>
- {jsSpec.functions.map((item, itemIndex) => {
- const hasTsRef = item['$ref'] || null
- const tsDefinition = hasTsRef && extractTsDocNode(hasTsRef, jsTypeSpec)
- const parameters = hasTsRef ? generateParameters(tsDefinition) : ''
-
- const functionMarkdownContent = props?.docs[itemIndex]?.content
- const shortText = hasTsRef ? tsDefinition.signatures[0].comment.shortText : ''
-
- // if (item.id !== 'db-modifiers-select') return <></>
-
- return (
- <>
- <RefSubLayout.Section
- key={item.id}
- title={
- examples.functions[itemIndex].title ??
- examples.functions[itemIndex].id ??
- item.name ??
- item.id
- }
- id={item.id}
- slug={commonLibSpec.functions.find((commonItem) => commonItem.id === item.id).slug}
- scrollSpyHeader={true}
- >
- <RefSubLayout.Details>
- <>
- <header className={['mb-16'].join(' ')}>
- {shortText && <ReactMarkdown className="text-sm">{shortText}</ReactMarkdown>}
- </header>
-
- {item.description && (
- <div className="prose">
- <ReactMarkdown className="text-sm">{item.description}</ReactMarkdown>
- </div>
- )}
- {functionMarkdownContent && (
- <div className="prose">
- <MDXRemote {...functionMarkdownContent} components={components} />
- </div>
- )}
- {item.notes && (
- <div className="prose">
- <ReactMarkdown className="text-sm">{item.notes}</ReactMarkdown>
- </div>
- )}
- {/* // parameters */}
- {parameters && (
- <div className="not-prose mt-12">
- <h5 className="mb-3 text-base text-scale-1200">Parameters</h5>
- <ul className="">
- {parameters.map((param) => {
- // grab override params from yaml file
- const overrideParams = item.overrideParams
-
- // params from the yaml file can override the params from parameters if it matches the name
- const overide = overrideParams?.filter((x) => {
- return param.name === x.name
- })
-
- const paramItem = overide?.length > 0 ? overide[0] : param
-
- return (
- <Param {...paramItem}>
- {paramItem.subContent && (
- <div className="mt-3">
- <Options>
- {param.subContent.map((param) => {
- return <Options.Option {...param} />
- })}
- </Options>
- </div>
- )}
- </Param>
- )
- })}
- </ul>
- </div>
- )}
- </>
- </RefSubLayout.Details>
- <RefSubLayout.Examples>
- {item.examples && (
+ <>
+ <RefSubLayout>
+ {jsSpec.functions.map((item, itemIndex) => {
+ const hasTsRef = item['$ref'] || null
+ const tsDefinition = hasTsRef && extractTsDocNode(hasTsRef, jsTypeSpec)
+ const parameters = hasTsRef ? generateParameters(tsDefinition) : ''
+
+ const functionMarkdownContent = props?.docs[itemIndex]?.content
+ const shortText = hasTsRef ? tsDefinition.signatures[0].comment.shortText : ''
+
+ // const introFileMarkdownContent =
+ console.log('props.docs', props.docs)
+ // if (item.id !== 'db-modifiers-select') return <></>
+
+ return (
+ <>
+ <div>Preamble pages</div>
+ {props.docs
+ .filter((doc) => doc.initialMarkdownPage)
+ .map((item) => (
+ <p>{item.id}</p>
+ ))}
+ <RefSubLayout.Section
+ key={item.id}
+ title={
+ examples.functions[itemIndex].title ??
+ examples.functions[itemIndex].id ??
+ item.name ??
+ item.id
+ }
+ id={item.id}
+ slug={commonLibSpec.functions.find((commonItem) => commonItem.id === item.id).slug}
+ scrollSpyHeader={true}
+ >
+ <RefSubLayout.Details>
<>
- <Tabs
- defaultActiveId={item.examples[0].id}
- size="tiny"
- type="rounded-pills"
- scrollable
- >
- {item.examples &&
- item.examples.map((example, exampleIndex) => {
- const exampleString = `
+ <header className={['mb-16'].join(' ')}>
+ {shortText && <ReactMarkdown className="text-sm">{shortText}</ReactMarkdown>}
+ </header>
+
+ {item.description && (
+ <div className="prose">
+ <ReactMarkdown className="text-sm">{item.description}</ReactMarkdown>
+ </div>
+ )}
+ {functionMarkdownContent && (
+ <div className="prose">
+ <MDXRemote {...functionMarkdownContent} components={components} />
+ </div>
+ )}
+ {item.notes && (
+ <div className="prose">
+ <ReactMarkdown className="text-sm">{item.notes}</ReactMarkdown>
+ </div>
+ )}
+ {/* // parameters */}
+ {parameters && (
+ <div className="not-prose mt-12">
+ <h5 className="mb-3 text-base text-scale-1200">Parameters</h5>
+ <ul className="">
+ {parameters.map((param) => {
+ // grab override params from yaml file
+ const overrideParams = item.overrideParams
+
+ // params from the yaml file can override the params from parameters if it matches the name
+ const overide = overrideParams?.filter((x) => {
+ return param.name === x.name
+ })
+
+ const paramItem = overide?.length > 0 ? overide[0] : param
+
+ return (
+ <Param {...paramItem}>
+ {paramItem.subContent && (
+ <div className="mt-3">
+ <Options>
+ {param.subContent.map((param) => {
+ return <Options.Option {...param} />
+ })}
+ </Options>
+ </div>
+ )}
+ </Param>
+ )
+ })}
+ </ul>
+ </div>
+ )}
+ </>
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
+ {item.examples && (
+ <>
+ <Tabs
+ defaultActiveId={item.examples[0].id}
+ size="tiny"
+ type="rounded-pills"
+ scrollable
+ >
+ {item.examples &&
+ item.examples.map((example, exampleIndex) => {
+ const exampleString = `
import { createClient } from '@supabase/supabase-js'
// 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
- const sql = staticExample?.data?.sql
- const tables = staticExample?.data?.tables
-
- const [dataOpen, setDataOpen] = useState(false)
-
- return (
- <Tabs.Panel
- id={example.id}
- label={example.name}
- className="flex flex-col gap-3"
- >
- <Accordion.Root className="transition-all ease-out flex flex-col">
- <Accordion.Trigger asChild>
- <button
- className={[
- 'transition-all ease-out',
- 'h-8',
- 'bg-scale-300 data-open:bg-scale-500',
- 'border border-scale-500 w-full flex items-center gap-3 px-5',
- 'data-open:bg-yellow-900',
- 'rounded-tl rounded-tr',
- 'data-closed:rounded-bl data-closed:rounded-br',
- 'text-scale-1100 text-xs',
- ].join(' ')}
- >
- <div className="data-open-parent:rotate-90 text-scale-900">
- <IconChevronRight size={12} strokeWidth={2} />
- </div>
- Example data source
- </button>
- </Accordion.Trigger>
- <Accordion.Content className="transition data-open:animate-slide-down data-closed:animate-slide-up">
- {tables &&
- tables.length > 0 &&
- tables.map((table) => {
- return (
- <div className="bg-scale-300 border rounded prose max-w-none">
- <div className="bg-scale-200 px-5 py-2">
- <div className="flex gap-2 items-center">
- <div className="text-brand-900">
- <IconDatabase size={16} />
+ const currentExampleId = example.id
+ const staticExample = item.examples[exampleIndex]
+
+ const response = staticExample.response
+ const sql = staticExample?.data?.sql
+ const tables = staticExample?.data?.tables
+
+ return (
+ <Tabs.Panel
+ id={example.id}
+ label={example.name}
+ className="flex flex-col gap-3"
+ >
+ <Accordion.Root className="transition-all ease-out flex flex-col">
+ <Accordion.Trigger asChild>
+ <button
+ className={[
+ 'transition-all ease-out',
+ 'h-8',
+ 'bg-scale-300 data-open:bg-scale-500',
+ 'border border-scale-500 w-full flex items-center gap-3 px-5',
+ 'data-open:bg-yellow-900',
+ 'rounded-tl rounded-tr',
+ 'data-closed:rounded-bl data-closed:rounded-br',
+ 'text-scale-1100 text-xs',
+ ].join(' ')}
+ >
+ <div className="data-open-parent:rotate-90 text-scale-900">
+ <IconChevronRight size={12} strokeWidth={2} />
+ </div>
+ Example data source
+ </button>
+ </Accordion.Trigger>
+ <Accordion.Content className="transition data-open:animate-slide-down data-closed:animate-slide-up">
+ {tables &&
+ tables.length > 0 &&
+ tables.map((table) => {
+ return (
+ <div className="bg-scale-300 border rounded prose max-w-none">
+ <div className="bg-scale-200 px-5 py-2">
+ <div className="flex gap-2 items-center">
+ <div className="text-brand-900">
+ <IconDatabase size={16} />
+ </div>
+ <h5 className="text-xs text-scale-1200">
+ {table.name}
+ </h5>
</div>
- <h5 className="text-xs text-scale-1200">
- {table.name}
- </h5>
</div>
</div>
- </div>
- )
- })}
- {sql && (
- <CodeBlock
- className="useless-code-block-class my-0 border border-scale-500 !rounded-tl-none !rounded-tr-none"
- language="sql"
- hideLineNumbers={true}
- >
- {sql}
- </CodeBlock>
- )}
- </Accordion.Content>
- </Accordion.Root>
- <CodeBlock
- className="useless-code-block-class"
- language="js"
- hideLineNumbers={true}
- >
- {exampleString +
- (example.code &&
- example.code
- .replace('```', '')
- .replace('js', '')
- .replace('```', ''))}
- </CodeBlock>
- {response && (
+ )
+ })}
+ {sql && (
+ <CodeBlock
+ className="useless-code-block-class my-0 border border-scale-500 !rounded-tl-none !rounded-tr-none"
+ language="sql"
+ hideLineNumbers={true}
+ >
+ {sql}
+ </CodeBlock>
+ )}
+ </Accordion.Content>
+ </Accordion.Root>
<CodeBlock
className="useless-code-block-class"
- language="json"
+ language="js"
hideLineNumbers={true}
>
- {response}
+ {exampleString +
+ (example.code &&
+ example.code
+ .replace('```', '')
+ .replace('js', '')
+ .replace('```', ''))}
</CodeBlock>
- )}
- </Tabs.Panel>
- )
- })}
- </Tabs>
- </>
- )}
- </RefSubLayout.Examples>
- </RefSubLayout.Section>
- </>
- )
- })}
- </RefSubLayout>
+ {response && (
+ <CodeBlock
+ className="useless-code-block-class"
+ language="json"
+ hideLineNumbers={true}
+ >
+ {response}
+ </CodeBlock>
+ )}
+ </Tabs.Panel>
+ )
+ })}
+ </Tabs>
+ </>
+ )}
+ </RefSubLayout.Examples>
+ </RefSubLayout.Section>
+ </>
+ )
+ })}
+ </RefSubLayout>
+ </>
)
}
export async function getStaticProps({ params }: { params: { slug: string[] } }) {
- const pages = jsSpec.functions.map((x) => x.id)
+ const initialMarkdownPages = ['typescript-support', 'release-notes']
+
+ const specPpages = jsSpec.functions.map((x) => x.id)
+
+ const pages = [...initialMarkdownPages, ...specPpages]
+ console.log('hello?', { pages })
/**
* Read all the markdown files that might have
@@ -293,6 +306,7 @@ export async function getStaticProps({ params }: { params: { slug: string[] } })
title: x,
// ...content,
meta: data,
+ initialMarkdownPage: initialMarkdownPages.includes(x),
content: content ? await serialize(content || '') : null,
}
})