Skip to content

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

Merge branch 'feat/docs2.0' of github.com:supabase/supabase into feat/docs2.0

Terry Suttonb1b9ee20db11
diff --cc apps/docs/pages/reference/javascript/v1/[...slug].tsx
index 5e2d8f2393b,e2d07c13bad..41b415343fa
--- a/apps/docs/pages/reference/javascript/v1/[...slug].tsx
+++ b/apps/docs/pages/reference/javascript/v1/[...slug].tsx
@@@ -32,18 -32,104 +32,20 @@@ import RefSubLayout from '~/layouts/ref
import OldLayout from '~/layouts/Default'
-const marginTop = 256
-export default function Ref(props) {
- // const myRef = useRef(null)
-
- console.log('props', props)
+export default function JSReference(props) {
+ const router = useRouter()
- const [offsetY, setOffsetY] = useState(0)
- const [sections, setSections] = useState([])
+ const slug = router.query.slug[0]
+ const isNewDocs = process.env.NEXT_PUBLIC_NEW_DOCS === 'true'
+
- // useEffect(() => {
- // window.scrollTo(0, 0)
- // setOffsetY(0)
- // }, [])
-
+ // When user lands on a url like http://supabase.com/docs/reference/javascript/sign-up
+ // find the #sign-up element and scroll to that
useEffect(() => {
- const els: HTMLElement[] = Array.from(document.querySelectorAll('div.ref-container'))
-
- const allSections = els.map((el: HTMLElement, index: number) => {
- const { top: boundingTop } = el.getBoundingClientRect()
-
- return {
- topic: el.getAttribute('id')!,
- boundingTop,
- isActive: index === 0,
- }
- })
-
- // console.log('allSections', allSections)
- setSections(allSections)
- }, [])
-
- // useEffect(() => {
- // if (sections.length <= 1) return
-
- // const onScroll = () => {
- // console.log('SCROLL EVENT')
- // setOffsetY(window.pageYOffset)
- // }
- // window.addEventListener('scroll', debounce(onScroll, 500))
-
- // return () => window.removeEventListener('scroll', onScroll)
- // }, [sections])
-
- // useEffect(() => {
- // if (sections.length === 0) return
-
- // if (sections.length === 1) {
- // sections[0].isActive = true
- // return
- // }
-
- // sections.forEach((section, index) => {
- // if (index === 0) {
- // section.isActive = sections[index + 1].boundingTop > offsetY + marginTop
- // } else {
- // if (sections[index + 1]) {
- // section.isActive =
- // sections[index + 1].boundingTop > offsetY + marginTop &&
- // sections[index].boundingTop <= offsetY + marginTop
- // } else {
- // section.isActive = sections[index].boundingTop <= offsetY + marginTop
- // }
- // }
- // })
- // }, [sections, offsetY])
-
- // useEffect(() => {
- // const observer = new IntersectionObserver((entries) => {
- // // console.log('entries', entries)
- // const entry = entries[0]
- // // console.log('entry', entry)
- // })
- // // console.log('myRef', myRef.current)
- // observer.observe(myRef.current)
- // }, [])
-
- const router = useRouter()
-
- function updateUrl(key) {
- // router.replace(
- // {
- // pathname: `/ref/js/${key}`,
- // // query: { sortBy: 'price' },
- // }
- // // undefined,
- // // { shallow: true }
- // )
- router.replace(
- {
- pathname: `/ref/js/${key}`,
- // query: { sortBy: 'price' },
- },
- undefined,
- { scroll: false }
- )
- }
+ if (document && slug !== 'start') {
+ // document.querySelector(`#${slug}`).scrollIntoView()
+ }
+ })
/*
* handle old ref pages