Migration 084: site defaults for the motion (slide, flip, fade, type, mirror), direction and seconds per word in Site settings, and a hero's and a block's own. The hero's headline, section and band titles, headings, paragraphs, callouts and quotes rotate; menus, tab titles, search text and emails show the first word; less motion shows it still. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.4 KiB
TypeScript
30 lines
1.4 KiB
TypeScript
/* ═══════════════════════════════════════════════════════════════
|
|
NAV SECTIONS: the sections listed under each page in the header's
|
|
dropdowns, the mobile menu and the footer's site map
|
|
|
|
Every page's list comes from the page itself, so adding, moving
|
|
or renaming a section changes the menus too (Pages → Page
|
|
management, GET /site-pages), the front page's included. The hero
|
|
and a countdown aren't listed: they're the top of a page, not a
|
|
place to jump to (sections/Bands.tsx).
|
|
═══════════════════════════════════════════════════════════════ */
|
|
|
|
import { useCallback } from 'react'
|
|
|
|
import { useSitePageHeadings } from './useSitePages.ts'
|
|
import { UNLISTED_PRESETS } from '../pages/sections/Bands.tsx'
|
|
import { firstWords } from '../lib/words.ts'
|
|
|
|
export type NavSection = { label: string; hash: string }
|
|
|
|
export function useNavSections(): (path: string) => NavSection[] {
|
|
const { data: sitePages } = useSitePageHeadings()
|
|
|
|
return useCallback(
|
|
(path: string) =>
|
|
(sitePages?.[path] ?? [])
|
|
.filter((section) => !UNLISTED_PRESETS.includes(section.preset ?? ''))
|
|
.map((section) => ({ label: firstWords(section.title), hash: `#${section.anchor}` })),
|
|
[sitePages],
|
|
)
|
|
}
|