import { Children, type ReactNode } from 'react' import { Link } from 'react-router-dom' import Markdown from 'react-markdown' import remarkGfm from 'remark-gfm' import { Search, ChevronRight, Loader2, AlertCircle, BookOpen, PanelLeft, X } from 'lucide-react' import PageShell from '../components/Layout/PageShell' import { useTranslation } from '../i18n' import { useHelp } from './help/useHelp' export default function HelpPage() { const { t } = useTranslation() const { page, loading, pageError, query, setQuery, navOpen, setNavOpen, contentRef, activeSlug, filtered } = useHelp() const nav = ( ) return (
{/* Desktop sidebar */} {/* Content */}
{/* Mobile nav toggle */} {loading ? (
) : pageError ? (

{t('help.errorTitle')}

{t('help.errorBody')}

) : page ? (
) : null}
{/* Mobile sidebar drawer */} {navOpen && (
setNavOpen(false)}>
e.stopPropagation()} >
{t('help.title')}
{nav}
)} ) } /** * GitHub's heading-anchor slug: lowercase, punctuation dropped, spaces to * hyphens. Wiki pages link to their own sections with `](#some-heading)`, and * those hrefs are written against GitHub's scheme — so ours has to match it, or * in-app anchors point at nothing. */ function headingId(children: ReactNode): string { const text = Children.toArray(children) .map(c => (typeof c === 'string' || typeof c === 'number' ? String(c) : '')) .join('') return text .toLowerCase() .replace(/[^\w\s-]/g, '') .trim() .replace(/\s+/g, '-') } /** Markdown renderer with TREK-styled elements and SPA-internal links. */ function WikiContent({ markdown }: { markdown: string }) { return ( (

{children}

), h2: ({ children }) => (

{children}

), h3: ({ children }) =>

{children}

, h4: ({ children }) =>

{children}

, p: ({ children }) =>

{children}

, ul: ({ children }) =>
    {children}
, ol: ({ children }) =>
    {children}
, li: ({ children }) =>
  • {children}
  • , a: ({ href, children }) => { const url = href ?? '' if (url.startsWith('#')) return {children} if (url.startsWith('/')) return {children} return ( {children} ) }, img: ({ src, alt }) => ( {alt} ), code: ({ className, children }) => { const isBlock = (className ?? '').includes('language-') if (isBlock) return {children} return {children} }, pre: ({ children }) => (
                {children}
              
    ), blockquote: ({ children }) => (
    {children}
    ), table: ({ children }) => (
    {children}
    ), th: ({ children }) => ( {children} ), td: ({ children }) => {children}, hr: () =>
    , }} > {markdown}
    ) }