The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Combine headings into one, fix scroll observer
Terry Sutton676ac5ef3cb1
diff --git a/apps/temp-docs/components/CustomMDX/CustomMDX.utils.ts b/apps/temp-docs/components/CustomMDX/CustomMDX.utils.tsindex 2ad270cae5a..af959573bee 100644--- a/apps/temp-docs/components/CustomMDX/CustomMDX.utils.ts+++ b/apps/temp-docs/components/CustomMDX/CustomMDX.utils.ts@@ -17,3 +17,19 @@ export const removeAnchor = (text: any) => {else return text}}++export const highlightSelectedTocItem = (id: string) => {+ const tocMenuItems = document.querySelectorAll('.toc-menu a')++ // find any currently active items and remove them+ const currentActiveItem = document.querySelector('.toc-menu .toc__menu-item--active')+ currentActiveItem?.classList.remove('toc__menu-item--active')++ // Add active class to the current item+ tocMenuItems.forEach((item) => {+ // @ts-ignore+ if (item.href.split('#')[1] === id) {+ item.classList.add('toc__menu-item--active')+ }+ })+}diff --git a/apps/temp-docs/components/CustomMDX/H2.tsx b/apps/temp-docs/components/CustomMDX/H2.tsxdeleted file mode 100644index 85ff9073bc9..00000000000--- a/apps/temp-docs/components/CustomMDX/H2.tsx+++ /dev/null@@ -1,17 +0,0 @@-import { getAnchor, removeAnchor } from './CustomMDX.utils'--const H2 = ({ children }) => {- const anchor = getAnchor(children)- const link = `#${anchor}`- return (- <h2 id={anchor} className="group flex gap-1 items-center scroll-mt-24">- {removeAnchor(children)}- {anchor && (- <a href={link} className="opacity-0 group-hover:opacity-100 transition">- #- </a>- )}- </h2>- )-}-export default H2diff --git a/apps/temp-docs/components/CustomMDX/H3.tsx b/apps/temp-docs/components/CustomMDX/H3.tsxdeleted file mode 100644index 65cb0fa382b..00000000000--- a/apps/temp-docs/components/CustomMDX/H3.tsx+++ /dev/null@@ -1,57 +0,0 @@-import { getAnchor, removeAnchor } from './CustomMDX.utils'--import { useInView } from 'react-intersection-observer'--// move this to a utils file if looks good-function highlightSelectedTocItem(id) {- const tocMenuItems = document.querySelectorAll('.toc-menu a')-- // remove all active items first- const currentActiveItem = document.querySelector('.toc-menu .toc__menu-item--active')- currentActiveItem?.classList.remove('toc__menu-item--active')-- // Add active class to the current item- tocMenuItems.forEach((item) => {- // @ts-ignore- if (item.href.split('#')[1] === id) {- item.classList.add('toc__menu-item--active')- }- })-}--const H3 = ({ children }) => {- const { ref, inView, entry } = useInView({- /* Optional options */- threshold: 0,- onChange: (inView, entry) => {- highlightSelectedTocItem(entry.target.id)- },- })-- // useEffect(() => {- // if (entry?.target) {- // //highlightSelectedTocItem(entry.target.id)- // }-- // //console.log(entry?.target?.id)- // }, [inView])-- const anchor = getAnchor(children)- const link = `#${anchor}`-- return (- <h3- id={anchor}- ref={ref}- className={`group flex gap-1 items-center scroll-mt-24 ${inView ? 'visible' : 'not-visible'}`}- >- {removeAnchor(children)}- {anchor && (- <a href={link} className="opacity-0 group-hover:opacity-100 transition">- #- </a>- )}- </h3>- )-}-export default H3diff --git a/apps/temp-docs/components/CustomMDX/H4.tsx b/apps/temp-docs/components/CustomMDX/H4.tsxdeleted file mode 100644index 2c7b9723973..00000000000--- a/apps/temp-docs/components/CustomMDX/H4.tsx+++ /dev/null@@ -1,17 +0,0 @@-import { getAnchor, removeAnchor } from './CustomMDX.utils'--const H4 = ({ children }) => {- const anchor = getAnchor(children)- const link = `#${anchor}`- return (- <h4 id={anchor} className="group flex gap-1 items-center scroll-mt-24">- {removeAnchor(children)}- {anchor && (- <a href={link} className="opacity-0 group-hover:opacity-100 transition">- #- </a>- )}- </h4>- )-}-export default H4diff --git a/apps/temp-docs/components/CustomMDX/Heading.tsx b/apps/temp-docs/components/CustomMDX/Heading.tsxnew file mode 100644index 00000000000..3d341630fd2--- /dev/null+++ b/apps/temp-docs/components/CustomMDX/Heading.tsx@@ -0,0 +1,29 @@+import { getAnchor, removeAnchor, highlightSelectedTocItem } from './CustomMDX.utils'+import { useInView } from 'react-intersection-observer'++const Heading = ({ tag, children }) => {+ const HeadingTag = `${tag}` as any++ const anchor = getAnchor(children)+ const link = `#${anchor}`++ // check if current heading is in view, update TOC active item accordingly+ const { ref, inView, entry } = useInView({+ threshold: 1,+ onChange: (inView, entry) => {+ if (inView) highlightSelectedTocItem(entry.target.id)+ },+ })++ return (+ <HeadingTag id={anchor} ref={ref} className="group flex gap-1 items-center scroll-mt-24">+ {removeAnchor(children)}+ {anchor && (+ <a href={link} className="opacity-0 group-hover:opacity-100 transition">+ #+ </a>+ )}+ </HeadingTag>+ )+}+export default Headingdiff --git a/apps/temp-docs/components/CustomMDX/index.tsx b/apps/temp-docs/components/CustomMDX/index.tsxindex c80de168c27..56ded7aefd1 100644--- a/apps/temp-docs/components/CustomMDX/index.tsx+++ b/apps/temp-docs/components/CustomMDX/index.tsx@@ -1,5 +1,3 @@-import H2 from './H2'-import H3 from './H3'-import H4 from './H4'+import Heading from './Heading'-export { H2, H3, H4 }+export { Heading }diff --git a/apps/temp-docs/components/index.tsx b/apps/temp-docs/components/index.tsxindex ec11a547c66..ac1329a01b7 100644--- a/apps/temp-docs/components/index.tsx+++ b/apps/temp-docs/components/index.tsx@@ -4,7 +4,7 @@ import CodeBlock from './CodeBlock/CodeBlock'import ButtonCard from './ButtonCard'import Frameworks from './Frameworks'import AuthProviders from './AuthProviders'-import { H2, H3, H4 } from './CustomMDX'+import { Heading } from './CustomMDX'const components = {Alert: (props: any) => (@@ -20,9 +20,23 @@ const components = {Tabs,TabPanel: (props: any) => <Tabs.Panel {...props}>{props.children}</Tabs.Panel>,- h2: H2,- h3: H3,- h4: H4,+ h2: (props: any) => (+ <Heading tag="h2" {...props}>+ {props.children}+ </Heading>+ ),++ h3: (props: any) => (+ <Heading tag="h3" {...props}>+ {props.children}+ </Heading>+ ),++ h4: (props: any) => (+ <Heading tag="h4" {...props}>+ {props.children}+ </Heading>+ ),code: (props: any) => <CodeBlock {...props} />,mono: (props: any) => <code className="text-sm">{props.children}</code>,}diff --git a/apps/temp-docs/docs/guides/cli/local-development.mdx b/apps/temp-docs/docs/guides/cli/local-development.mdxindex 12751bc280f..04df0a1983e 100644--- a/apps/temp-docs/docs/guides/cli/local-development.mdx+++ b/apps/temp-docs/docs/guides/cli/local-development.mdx@@ -9,19 +9,6 @@ import TabItem from '@theme/TabItem'Learn how to use the Supabase CLI to develop your project locally and deploy to the Supabase Platform.-:::note-To access the database from an edge function in your local Supabase setup, replace `localhost` with `host.docker.internal`.-:::--<h3>this is a proper heading</h3>--### this is a proper md heading--<Alert title="Title of the alert" withIcon variant="warning">- To access the database from an edge function in your local Supabase setup, replace `localhost`- with `host.docker.internal`.-</Alert>-## PrerequisitesMake sure you have these installed on your local machine:diff --git a/apps/temp-docs/layouts/Default.tsx b/apps/temp-docs/layouts/Default.tsxindex 157d0c41747..bf7bffaae77 100644--- a/apps/temp-docs/layouts/Default.tsx+++ b/apps/temp-docs/layouts/Default.tsx@@ -61,7 +61,7 @@ const Layout: FC<Props> = ({ meta, children, toc, menuItems, currentPage }) => {<ul className="toc-menu list-none pl-4 text-[0.8rem] grid gap-1 mt-1">{toc.json.map((item: any, i: number) => {return (- <li key={i}>+ <li key={i} className={`${item.lvl === 3 ? 'ml-4' : ''}`}><aclassName="text-scale-1000 hover:text-brand-900 transition-colors"href={`#${item.slug}`}