mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? push client directive to leaf interactive components, keep content in server shell ## What is the current behavior? /pricing and blog pages are rendered it client side so crawlers don't get any content on fetch. Verifiy content with ```bash curl -s http://localhost:3000/pricing | sed 's/<script[^>]*>.*<\/script>//g; s/<style[^>]*>.*<\/style>//g; s/<[^>]*>//g' | wc -w curl -s http://localhost:3000/blog | sed 's/<script[^>]*>.*<\/script>//g; s/<style[^>]*>.*<\/style>//g; s/<[^>]*>//g' | wc -w curl -s http://localhost:3000/blog/<some-slug> | sed 's/<script[^>]*>.*<\/script>//g; s/<style[^>]*>.*<\/style>//g; s/<[^>]*>//g' | wc -w ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Featured blog post now displays prominently on the blog landing page * Added smooth anchor link navigation on the pricing page * Improved table of contents tracking with scroll-to-anchor behavior on blog posts * Enhanced pricing comparison and plans sections with better data integration <!-- end of auto-generated comment: release notes by coderabbit.ai -->
30 lines
836 B
TypeScript
30 lines
836 B
TypeScript
'use client'
|
|
|
|
import { usePathname } from 'next/navigation'
|
|
import { useEffect } from 'react'
|
|
|
|
// Scrolls to the section matching window.location.hash on mount and on
|
|
// pathname change. We render a mobile and a desktop row for each item, so the
|
|
// id-based anchors are suffixed with `-mobile` / `-desktop` and we pick the
|
|
// right one based on viewport width.
|
|
export default function HashAnchorScroll() {
|
|
const pathname = usePathname()
|
|
|
|
useEffect(() => {
|
|
const hash = window.location.hash.slice(1)
|
|
if (!hash) return
|
|
|
|
let device = 'desktop'
|
|
if (window.matchMedia('screen and (max-width: 1024px)').matches) {
|
|
device = 'mobile'
|
|
}
|
|
|
|
const element = document.querySelector(`#${hash}-${device}`)
|
|
if (element) {
|
|
element.scrollIntoView({ behavior: 'smooth' })
|
|
}
|
|
}, [pathname])
|
|
|
|
return null
|
|
}
|