Skip to content

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

Update CLI config page

Terry Suttonc47794a217b6
diff --git a/apps/docs/components/CustomHTMLElements/Heading.tsx b/apps/docs/components/CustomHTMLElements/Heading.tsx
index f1248c38d1c..74f3511b110 100644
--- a/apps/docs/components/CustomHTMLElements/Heading.tsx
+++ b/apps/docs/components/CustomHTMLElements/Heading.tsx
@@ -14,12 +14,22 @@ import { useInView } from 'react-intersection-observer'
*/
interface Props {
- tag: string
+ tag?: string
+ parseAnchors?: boolean
+ customAnchor?: string
}
-const Heading: React.FC<Props> = ({ tag, children }) => {
+/**
+ * This TOC is used in .mdx files and in .tsx files.
+ * In mdx files, we need to parse the content and format them to match the
+ * expected tocList format (text, link,level).
+ *
+ * In tsx files, we can generate this tocList directly. For these files, we don't
+ * need to parse the <a> and generate anchors
+ */
+const Heading: React.FC<Props> = ({ tag, parseAnchors = false, customAnchor, children }) => {
const HeadingTag = `${tag}` as any
- const anchor = getAnchor(children)
+ const anchor = customAnchor ? customAnchor : getAnchor(children)
const link = `#${anchor}`
const { ref } = useInView({
@@ -33,7 +43,7 @@ const Heading: React.FC<Props> = ({ tag, children }) => {
return (
<HeadingTag id={anchor} ref={ref} className="group scroll-mt-24">
- {removeAnchor(children)}
+ {parseAnchors ? removeAnchor(children) : children}
{anchor && (
<a href={link} className="ml-2 opacity-0 group-hover:opacity-100 transition">
#
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx
index ad27088356f..ad8e934e6e6 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx
@@ -128,6 +128,9 @@ const NavigationMenu = () => {
case url.includes(`/docs/reference/python`) && url:
menuState.setMenuLevelId('reference_python_v2')
break
+ case url.includes(`/docs/reference/cli/config`) && url:
+ menuState.setMenuLevelId('supabase_cli')
+ break
case url.includes(`/docs/reference/cli`) && url:
menuState.setMenuLevelId('reference_cli')
break
diff --git a/apps/docs/pages/reference/cli/config.tsx b/apps/docs/pages/reference/cli/config.tsx
index f472a9a8d58..3453d44e312 100644
--- a/apps/docs/pages/reference/cli/config.tsx
+++ b/apps/docs/pages/reference/cli/config.tsx
@@ -2,16 +2,31 @@
import specFile from '~/../../spec/cli_v1_config.yaml' assert { type: 'yml' }
import { Parameter } from '~/lib/refGenerator/refTypes'
import ReactMarkdown from 'react-markdown'
+import GuidesTableOfContents from '~/components/GuidesTableOfContents'
+import { Heading } from '~/components/CustomHTMLElements'
// Parameters are grouped on the page by tag
const TAGS = ['general', 'auth', 'api', 'database', 'dashboard', 'local', 'edge-functions']
+const tocList = TAGS.map((tag) =>
+ specFile.parameters
+ .filter((param: Parameter) => param.tags[0] === tag)
+ .map((parameter) => {
+ console.log('the param', parameter)
+ const text = parameter.id
+ const link = `#${parameter.id}`
+ const level = '2'
+ return { text, link, level }
+ })
+).flat()
+
export default function Config() {
return (
- <div>
- <div className="flex my-16">
+ <div className="grid grid-cols-12 relative gap-4">
+ <div className="relative col-span-12 md:col-span-9 transition-all ease-out duration-100">
<div className="w-full prose">
- <h1 className="text-4xl mb-16">{specFile.info.title}</h1>
+ <h1 className="">CLI configuration</h1>
+ <div className="max-w-xs w-32 h-[1px] bg-gradient-to-r from-brand-800 to-brand-900 my-8"></div>
<ReactMarkdown>{specFile.info.description}</ReactMarkdown>
<div>
{TAGS.map((tag) =>
@@ -22,11 +37,11 @@ export default function Config() {
{index === 0 && <h2 className="text-xl capitalize">{tag}</h2>}
<div className="mt-8">
<div>
- <h2 className="text-xl font-medium text-scale-1200 font-mono">
+ <Heading tag="h2" parseAnchors={false} customAnchor={parameter.id}>
<span className="mr-2">$</span>
{parameter.title}
- </h2>
- <div className="grid" id={parameter.id}>
+ </Heading>
+ <div className="grid">
<div className="border-b pb-8" key={parameter.id}>
<div className=" mb-16">
<p className="mb-4 scroll-mt-16 mt-0 text-scale-1100 text-base">
@@ -63,6 +78,14 @@ export default function Config() {
</div>
</div>
</div>
+ <div className="md:col-span-3">
+ <div className="sticky top-20 border-l">
+ <span className="block font-mono text-xs uppercase text-scale-1200 pl-5 mb-4">
+ On this page
+ </span>
+ <GuidesTableOfContents list={tocList} />
+ </div>
+ </div>
</div>
)
}