feat: new documentation

This commit is contained in:
swve
2026-03-14 12:39:57 +01:00
parent c6ffd76538
commit c0d8d90ec4
168 changed files with 11830 additions and 11996 deletions

View File

@@ -0,0 +1,47 @@
'use client'
import posthog from 'posthog-js'
import { PostHogProvider as PHProvider, usePostHog } from 'posthog-js/react'
import { usePathname, useSearchParams } from 'next/navigation'
import { useEffect, Suspense } from 'react'
if (typeof window !== 'undefined' && process.env.NEXT_PUBLIC_POSTHOG_KEY) {
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST || 'https://us.i.posthog.com',
capture_pageview: false,
capture_pageleave: true,
})
}
function PostHogPageView() {
const pathname = usePathname()
const searchParams = useSearchParams()
const posthog = usePostHog()
useEffect(() => {
if (pathname && posthog) {
let url = window.origin + pathname
if (searchParams.toString()) {
url = url + '?' + searchParams.toString()
}
posthog.capture('$pageview', { $current_url: url })
}
}, [pathname, searchParams, posthog])
return null
}
export default function PostHogProvider({ children }) {
if (!process.env.NEXT_PUBLIC_POSTHOG_KEY) {
return children
}
return (
<PHProvider client={posthog}>
<Suspense fallback={null}>
<PostHogPageView />
</Suspense>
{children}
</PHProvider>
)
}

View File

@@ -0,0 +1,159 @@
'use client'
import { ReactFlow, Background, MarkerType } from '@xyflow/react'
import '@xyflow/react/dist/style.css'
import {
SiNextdotjs,
SiFastapi,
SiPostgresql,
SiRedis,
SiStripe,
SiGooglegemini,
SiSentry,
SiUnsplash,
} from '@icons-pack/react-simple-icons'
import {
Users,
PencilSimple,
HardDrives,
Envelope,
Terminal,
Key,
ChartBar,
} from '@phosphor-icons/react/dist/ssr'
const nodeDefaults = {
draggable: false,
connectable: false,
selectable: false,
}
function NodeLabel({ icon, label, sub }) {
return (
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<span style={{ flexShrink: 0, display: 'flex' }}>{icon}</span>
<div style={{ textAlign: 'left' }}>
<div style={{ fontSize: 12, fontWeight: 600, color: '#1a1a1a', lineHeight: 1.3 }}>{label}</div>
{sub && <div style={{ fontSize: 9.5, color: '#6b7280', lineHeight: 1.3 }}>{sub}</div>}
</div>
</div>
)
}
const makeNode = (id, icon, label, sub, x, y, bg, border, width = 155) => ({
id,
position: { x, y },
data: { label: <NodeLabel icon={icon} label={label} sub={sub} /> },
style: {
background: bg,
border: `1px solid ${border}`,
borderRadius: 12,
padding: '10px 14px',
width,
},
...nodeDefaults,
})
const nodes = [
// Row 0 — Users
makeNode('users', <Users size={16} weight="fill" color="#6366f1" />, 'Users', 'Browser', 265, 0, '#f0f4ff', '#c7d2fe'),
// Row 1 — Core apps
makeNode('web', <SiNextdotjs size={14} color="#000" />, 'Web', 'Next.js 16', 30, 120, '#e0f2fe', '#93c5fd'),
makeNode('api', <SiFastapi size={14} color="#009688" />, 'API', 'FastAPI', 265, 120, '#dcfce7', '#86efac'),
makeNode('collab', <PencilSimple size={14} weight="fill" color="#db2777" />, 'Collab', 'Hocuspocus', 500, 120, '#fce7f3', '#f9a8d4'),
// Row 2 — Data layer
makeNode('pg', <SiPostgresql size={14} color="#4169E1" />, 'PostgreSQL', 'pgvector', 145, 260, '#f3e8ff', '#c4b5fd'),
makeNode('redis', <SiRedis size={14} color="#DC382D" />, 'Redis', 'Cache & Sessions', 385, 260, '#fef9c3', '#fde047'),
// Row 3 — External services (API)
makeNode('gemini', <SiGooglegemini size={13} color="#8E75B2" />, 'Google Gemini', 'AI & RAG', 0, 400, '#ecfdf5', '#6ee7b7', 145),
makeNode('s3', <HardDrives size={14} weight="fill" color="#E25D10" />, 'S3 Storage', 'Media files', 165, 400, '#fff7ed', '#fdba74', 145),
makeNode('stripe', <SiStripe size={13} color="#635BFF" />, 'Stripe', 'Payments', 330, 400, '#eef2ff', '#a5b4fc', 145),
makeNode('email', <Envelope size={14} weight="fill" color="#EF4444" />, 'Email', 'Resend / SMTP', 495, 400, '#fef2f2', '#fca5a5', 145),
// Row 4 — More services
makeNode('judge0', <Terminal size={14} weight="fill" color="#16A34A" />, 'Judge0', 'Code execution', 0, 490, '#f0fdf4', '#86efac', 145),
makeNode('workos', <Key size={14} weight="fill" color="#7C3AED" />, 'WorkOS', 'Enterprise SSO', 165, 490, '#fdf4ff', '#d8b4fe', 145),
makeNode('sentry', <SiSentry size={13} color="#362D59" />, 'Sentry', 'Error tracking', 330, 490, '#faf5ff', '#c4b5fd', 145),
makeNode('tinybird', <ChartBar size={14} weight="fill" color="#0d9488" />, 'Tinybird', 'Analytics', 495, 490, '#f0fdfa', '#5eead4', 145),
// Web → Unsplash
makeNode('unsplash', <SiUnsplash size={12} color="#000" />, 'Unsplash', 'Stock images', 30, 260, '#f5f5f4', '#d6d3d1', 105),
]
const solid = {
type: 'default',
style: { stroke: '#94a3b8', strokeWidth: 1.5 },
markerEnd: { type: MarkerType.ArrowClosed, color: '#94a3b8', width: 14, height: 14 },
}
const dashed = {
type: 'default',
style: { stroke: '#cbd5e1', strokeWidth: 1.2, strokeDasharray: '5 4' },
markerEnd: { type: MarkerType.ArrowClosed, color: '#cbd5e1', width: 12, height: 12 },
}
const edges = [
// Users → Core apps
{ id: 'u-web', source: 'users', target: 'web', label: 'HTTP', ...solid },
{ id: 'u-api', source: 'users', target: 'api', label: 'REST', ...solid },
{ id: 'u-collab', source: 'users', target: 'collab', label: 'WebSocket', ...solid },
// Inter-app
{ id: 'web-api', source: 'web', target: 'api', label: 'SSR', ...solid },
{ id: 'collab-api', source: 'collab', target: 'api', label: 'Persist', ...solid },
// Data stores
{ id: 'api-pg', source: 'api', target: 'pg', ...solid },
{ id: 'api-redis', source: 'api', target: 'redis', ...solid },
{ id: 'collab-redis', source: 'collab', target: 'redis', label: 'Cache', ...solid },
// API → External
{ id: 'api-gemini', source: 'api', target: 'gemini', ...dashed },
{ id: 'api-s3', source: 'api', target: 's3', ...dashed },
{ id: 'api-stripe', source: 'api', target: 'stripe', ...dashed },
{ id: 'api-email', source: 'api', target: 'email', ...dashed },
{ id: 'api-judge0', source: 'api', target: 'judge0', ...dashed },
{ id: 'api-workos', source: 'api', target: 'workos', ...dashed },
{ id: 'api-sentry', source: 'api', target: 'sentry', ...dashed },
{ id: 'api-tinybird', source: 'api', target: 'tinybird', ...dashed },
// Web → External
{ id: 'web-unsplash', source: 'web', target: 'unsplash', ...dashed },
{ id: 'web-sentry', source: 'web', target: 'sentry', ...dashed },
]
export default function ArchitectureDiagram() {
return (
<div style={{
border: '1px solid #e5e7eb',
borderRadius: 16,
overflow: 'hidden',
background: '#fafafa',
margin: '24px 0',
height: 620,
}}>
<ReactFlow
nodes={nodes}
edges={edges}
fitView
fitViewOptions={{ padding: 0.12 }}
panOnDrag={false}
zoomOnScroll={false}
zoomOnPinch={false}
zoomOnDoubleClick={false}
preventScrolling={false}
nodesDraggable={false}
nodesConnectable={false}
elementsSelectable={false}
proOptions={{ hideAttribution: true }}
>
<Background color="#e5e7eb" gap={20} size={1} />
</ReactFlow>
</div>
)
}

View File

@@ -0,0 +1,56 @@
'use client'
import { useState, useRef, useCallback } from 'react'
function CopyButton({ getText }) {
const [copied, setCopied] = useState(false)
const handleCopy = useCallback(async () => {
const text = getText()
if (!text) return
try {
await navigator.clipboard.writeText(text)
setCopied(true)
setTimeout(() => setCopied(false), 2000)
} catch {}
}, [getText])
return (
<button className="lh-code-copy" onClick={handleCopy} aria-label="Copy code">
{copied ? (
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">
<polyline points="20 6 9 17 4 12" />
</svg>
) : (
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2" />
<path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1" />
</svg>
)}
</button>
)
}
export default function CodeBlock({ children, 'data-filename': filename, 'data-language': language, ...props }) {
const codeRef = useRef(null)
const getText = useCallback(() => {
if (!codeRef.current) return ''
return codeRef.current.textContent || ''
}, [])
return (
<div className="lh-code-block">
{filename && (
<div className="lh-code-header">
<span className="lh-code-filename">{filename}</span>
<CopyButton getText={getText} />
</div>
)}
<div className="lh-code-body" ref={codeRef}>
{!filename && <CopyButton getText={getText} />}
<pre>{children}</pre>
</div>
</div>
)
}

View File

@@ -0,0 +1,125 @@
'use client'
import Link from 'next/link'
import {
PencilSimple,
Brain,
UsersThree,
BookOpen,
ClipboardText,
Terminal,
ChatCircle,
ChalkboardSimple,
Microphone,
Certificate,
ChartBar,
CreditCard,
Buildings,
ShieldCheck,
MagnifyingGlass,
} from '@phosphor-icons/react/dist/ssr'
const features = [
// Row 1 — hero features (large)
{ icon: PencilSimple, label: 'Block Editor', desc: 'Notion-like WYSIWYG editor with rich content blocks, videos, documents, and embeds', color: '#3b82f6', size: 'large', href: '/platform/editor' },
{ icon: Brain, label: 'AI Tutoring', desc: 'Built-in AI assistant for students and teachers with RAG-powered context', color: '#a855f7', size: 'large', href: '/platform/ai' },
{ icon: UsersThree, label: 'Real-time Collaboration', desc: 'Live co-editing for course content and boards powered by Hocuspocus', color: '#ec4899', size: 'large', href: '/platform/editor/collaboration' },
// Row 2+ — standard features
{ icon: BookOpen, label: 'Courses & Trails', desc: 'Chapters, activities, collections, and learning paths', color: '#10b981', href: '/platform/courses' },
{ icon: ClipboardText, label: 'Assignments', desc: 'Automated and manual grading', color: '#f59e0b', href: '/platform/assignments' },
{ icon: Terminal, label: 'Code Execution', desc: 'Run code in 7+ languages', color: '#8b5cf6', href: '/platform/code-execution' },
{ icon: ChatCircle, label: 'Discussions', desc: 'Threaded conversations', color: '#f43f5e', href: '/platform/discussions' },
{ icon: ChalkboardSimple, label: 'Boards', desc: 'Collaborative whiteboards', color: '#f97316', href: '/platform/boards' },
{ icon: Microphone, label: 'Podcasts', desc: 'Audio content and episodes', color: '#ec4899', href: '/platform/podcasts' },
{ icon: Certificate, label: 'Certifications', desc: 'Auto-generate on completion', color: '#14b8a6', href: '/platform/certifications' },
{ icon: ChartBar, label: 'Analytics', desc: 'Track progress and engagement', color: '#d97706', href: '/platform/analytics' },
{ icon: CreditCard, label: 'Payments', desc: 'Sell courses with Stripe', color: '#6366f1', href: '/platform/payments' },
{ icon: Buildings, label: 'Multi-tenancy', desc: 'Multiple organizations', color: '#0891b2', href: '/platform/organizations/multi-tenancy' },
{ icon: ShieldCheck, label: 'Enterprise SSO', desc: 'WorkOS SAML/OIDC', color: '#475569', href: '/platform/users/authentication' },
{ icon: MagnifyingGlass, label: 'Search', desc: 'Full-text search', color: '#737373', href: '/platform/search' },
]
function FeatureCard({ icon: Icon, label, color, desc, large, href }) {
return (
<Link
href={href}
style={{
padding: large ? '24px 26px' : '18px 20px',
borderRadius: 16,
background: '#fff',
overflow: 'hidden',
position: 'relative',
display: 'flex',
flexDirection: 'column',
gap: large ? 14 : 10,
boxShadow: '0 1px 3px rgba(0,0,0,0.04), 0 0 0 1px rgba(0,0,0,0.03)',
textDecoration: 'none',
transition: 'transform 0.15s ease, box-shadow 0.15s ease',
}}
onMouseEnter={e => { e.currentTarget.style.transform = 'scale(1.02)'; e.currentTarget.style.boxShadow = '0 4px 16px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04)' }}
onMouseLeave={e => { e.currentTarget.style.transform = 'scale(1)'; e.currentTarget.style.boxShadow = '0 1px 3px rgba(0,0,0,0.04), 0 0 0 1px rgba(0,0,0,0.03)' }}
>
{/* Dot pattern */}
<div
style={{
position: 'absolute',
inset: 0,
pointerEvents: 'none',
opacity: 1,
backgroundImage: `radial-gradient(${color}30 1px, transparent 1px)`,
backgroundSize: '14px 14px',
maskImage: 'linear-gradient(to bottom, black 0%, transparent 50%)',
WebkitMaskImage: 'linear-gradient(to bottom, black 0%, transparent 50%)',
}}
/>
<div
style={{
width: large ? 40 : 34,
height: large ? 40 : 34,
borderRadius: large ? 12 : 10,
background: color + '10',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
}}
>
<Icon size={large ? 20 : 17} weight="duotone" style={{ color }} />
</div>
<div>
<div style={{ fontSize: large ? 15 : 13, fontWeight: 650, color: '#1a1a1a', lineHeight: 1.3, margin: 0 }}>
{label}
</div>
<div style={{ fontSize: large ? 13 : 11.5, color: '#9ca3af', lineHeight: 1.45, margin: 0, marginTop: 3 }}>
{desc}
</div>
</div>
</Link>
)
}
export default function FeaturesGrid() {
const heroFeatures = features.filter(f => f.size === 'large')
const standardFeatures = features.filter(f => !f.size)
return (
<div style={{ margin: '24px 0', display: 'flex', flexDirection: 'column', gap: 10 }}>
{/* Hero row — 3 large cards */}
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 10 }}>
{heroFeatures.map(f => (
<FeatureCard key={f.label} {...f} large />
))}
</div>
{/* Standard features — compact bento grid */}
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 10 }}>
{standardFeatures.map(f => (
<FeatureCard key={f.label} {...f} />
))}
</div>
</div>
)
}

View File

@@ -0,0 +1,36 @@
'use client'
import Link from 'next/link'
const links = [
{ label: 'Documentation', href: '/' },
{ label: 'GitHub', href: 'https://github.com/learnhouse/learnhouse' },
{ label: 'Discord', href: 'https://discord.gg/CMyZjjYZ6x' },
{ label: 'Twitter', href: 'https://twitter.com/learnhouseapp' },
]
export default function Footer() {
return (
<footer className="lh-footer">
<div className="lh-footer-container">
<p className="lh-footer-copyright">
&copy; {new Date().getFullYear()} LearnHouse
</p>
<nav className="lh-footer-nav">
{links.map((link) => {
const isExternal = link.href.startsWith('http')
const Tag = isExternal ? 'a' : Link
const props = isExternal
? { href: link.href, target: '_blank', rel: 'noopener noreferrer' }
: { href: link.href }
return (
<Tag key={link.label} {...props} className="lh-footer-link">
{link.label}
</Tag>
)
})}
</nav>
</div>
</footer>
)
}

View File

@@ -0,0 +1,111 @@
'use client'
import Link from 'next/link'
import {
RocketLaunch,
BookOpen,
Cloud,
Code,
} from '@phosphor-icons/react/dist/ssr'
const cards = [
{
href: '/getting-started',
icon: RocketLaunch,
color: '#6366f1',
title: 'Getting Started',
desc: 'Set up your first organization and course in minutes',
pattern: 'radial-gradient(circle, currentColor 1px, transparent 1px)',
patternSize: '14px 14px',
},
{
href: '/platform',
icon: BookOpen,
color: '#10b981',
title: 'Platform Guide',
desc: 'Courses, editor, AI, assignments, and more',
pattern: 'linear-gradient(currentColor 1px, transparent 1px), linear-gradient(90deg, currentColor 1px, transparent 1px)',
patternSize: '20px 20px',
},
{
href: '/self-hosting',
icon: Cloud,
color: '#f97316',
title: 'Self Hosting',
desc: 'Deploy on your own infrastructure with the CLI',
pattern: 'repeating-linear-gradient(45deg, currentColor 0px, currentColor 1px, transparent 1px, transparent 8px)',
patternSize: '12px 12px',
},
{
href: '/developers',
icon: Code,
color: '#8b5cf6',
title: 'Developers',
desc: 'Architecture, REST API, and contributing guide',
pattern: 'repeating-linear-gradient(0deg, currentColor 0px, currentColor 1px, transparent 1px, transparent 6px)',
patternSize: '6px 6px',
},
]
export default function HomeCards() {
return (
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: 12, margin: '32px 0' }}>
{cards.map((card) => {
const Icon = card.icon
return (
<Link
key={card.href}
href={card.href}
className="nice-shadow"
style={{
display: 'flex', alignItems: 'center', gap: 16,
padding: '22px 24px',
borderRadius: 16,
background: '#fff',
overflow: 'hidden',
position: 'relative',
textDecoration: 'none',
transition: 'transform 0.15s ease',
}}
onMouseEnter={e => e.currentTarget.style.transform = 'scale(1.02)'}
onMouseLeave={e => e.currentTarget.style.transform = 'scale(1)'}
>
{/* Pattern */}
<div
style={{
position: 'absolute', inset: 0,
pointerEvents: 'none',
opacity: 0.05,
color: card.color,
backgroundImage: card.pattern,
backgroundSize: card.patternSize,
maskImage: 'linear-gradient(to right, black 0%, transparent 60%)',
WebkitMaskImage: 'linear-gradient(to right, black 0%, transparent 60%)',
}}
/>
{/* Icon */}
<div
style={{
position: 'relative', zIndex: 1,
flexShrink: 0,
width: 42, height: 42,
borderRadius: 12,
display: 'flex', alignItems: 'center', justifyContent: 'center',
backgroundColor: card.color + '10',
}}
>
<Icon size={20} weight="duotone" style={{ color: card.color }} />
</div>
{/* Text */}
<div style={{ position: 'relative', zIndex: 1, minWidth: 0 }}>
<div style={{ fontSize: 15, fontWeight: 650, color: '#1a1a1a', lineHeight: 1.3, margin: 0 }}>{card.title}</div>
<div style={{ fontSize: 13, color: '#9ca3af', lineHeight: 1.45, margin: 0, marginTop: 3 }}>{card.desc}</div>
</div>
</Link>
)
})}
</div>
)
}

View File

@@ -1,28 +1,11 @@
'use client'
import Image from "next/image";
import React from "react";
function Logo() {
const [colorScheme, setColorScheme] = React.useState("");
React.useEffect(() => {
const rootElement = window.document.documentElement;
const computedStyle = window.getComputedStyle(rootElement);
const colorSchemeValue = computedStyle.getPropertyValue("color-scheme").trim();
setColorScheme(colorSchemeValue);
}, []);
return (
<div>
{colorScheme === "dark" ? (
<Image style={{ paddingTop: 35, paddingBottom: 35, paddingRight: 30 }} width={185} height={35} src="/img/logos/white_logo.png" alt="Dark Logo" />
) : (
<Image style={{ paddingTop: 35, paddingBottom: 35, paddingRight: 30 }} width={185} height={35} src="/img/logos/black_logo.png" alt="Light Logo" />
)}
</div>
);
<img
src="/img/logos/learnhouse-dark.svg"
alt="LearnHouse"
style={{ height: 20, width: 'auto' }}
/>
)
}
export default Logo;
export default Logo

View File

@@ -0,0 +1,167 @@
'use client'
import { useTheme } from 'next-themes'
import { useEffect, useState } from 'react'
import Link from 'next/link'
import { Search } from 'nextra/components'
import { GithubLogo, DiscordLogo, Code, ArrowUpRight, List, X, Plug, Globe, GraduationCap } from '@phosphor-icons/react/dist/ssr'
function Navbar() {
const { resolvedTheme } = useTheme()
const [mounted, setMounted] = useState(false)
const [mobileMenuOpen, setMobileMenuOpen] = useState(false)
useEffect(() => setMounted(true), [])
// Close mobile menu on route change
useEffect(() => {
const handleRouteChange = () => setMobileMenuOpen(false)
window.addEventListener('popstate', handleRouteChange)
return () => window.removeEventListener('popstate', handleRouteChange)
}, [])
// Prevent body scroll when mobile menu is open
useEffect(() => {
if (mobileMenuOpen) {
document.body.style.overflow = 'hidden'
} else {
document.body.style.overflow = ''
}
return () => { document.body.style.overflow = '' }
}, [mobileMenuOpen])
const logoSrc = '/img/logos/learnhouse-dark.svg'
return (
<>
<div className="lh-navbar">
<div className="lh-navbar-inner">
{/* Left: logo + nav */}
<div className="lh-navbar-left">
<Link href="/" className="lh-navbar-logo">
{mounted ? (
<img src={logoSrc} alt="LearnHouse" />
) : (
<div style={{ width: 100, height: 20 }} />
)}
</Link>
<span className="lh-navbar-badge -ml-4 mt-[1px] text-[10px] font-bold tracking-wider rounded-[5px] px-1.5 py-[2.5px]" style={{ fontFamily: "'Wix Madefor Display', sans-serif" }}>Docs</span>
<nav className="lh-navbar-nav lh-hide-mobile">
<Link
href="/developers"
className="lh-navbar-nav-item"
>
<Code size={15} weight="fill" />
Developers
</Link>
<a
href="https://university.learnhouse.io"
target="_blank"
rel="noopener noreferrer"
className="lh-navbar-nav-item"
>
<GraduationCap size={15} weight="fill" />
Learn
<ArrowUpRight size={11} weight="bold" />
</a>
<a
href="https://learnhouse.app/integrations"
target="_blank"
rel="noopener noreferrer"
className="lh-navbar-nav-item"
>
<Plug size={15} weight="fill" />
Integrations
<ArrowUpRight size={11} weight="bold" />
</a>
<a
href="https://learnhouse.app"
target="_blank"
rel="noopener noreferrer"
className="lh-navbar-nav-item"
>
<Globe size={15} weight="fill" />
Website
<ArrowUpRight size={11} weight="bold" />
</a>
</nav>
</div>
{/* Right: search + links + hamburger */}
<div className="lh-navbar-right">
<Search className="lh-navbar-search" placeholder="Search docs..." />
<a
href="https://github.com/learnhouse/learnhouse"
target="_blank"
rel="noopener noreferrer"
className="lh-navbar-nav-item lh-hide-mobile"
>
<GithubLogo size={16} weight="fill" />
GitHub
</a>
<a
href="https://discord.gg/CMyZjjYZ6x"
target="_blank"
rel="noopener noreferrer"
className="lh-navbar-nav-item lh-hide-mobile"
>
<DiscordLogo size={16} weight="fill" />
Discord
</a>
{/* Mobile hamburger */}
<button
className="lh-mobile-menu-btn"
onClick={() => setMobileMenuOpen(!mobileMenuOpen)}
aria-label={mobileMenuOpen ? 'Close menu' : 'Open menu'}
>
{mobileMenuOpen ? <X size={20} weight="bold" /> : <List size={20} weight="bold" />}
</button>
</div>
</div>
</div>
{/* Mobile menu overlay */}
{mobileMenuOpen && (
<div className="lh-mobile-overlay" onClick={() => setMobileMenuOpen(false)} />
)}
{/* Mobile sidebar drawer */}
<div className={`lh-mobile-drawer ${mobileMenuOpen ? 'lh-mobile-drawer-open' : ''}`}>
<div className="lh-mobile-drawer-links">
<Link href="/developers" className="lh-mobile-drawer-link" onClick={() => setMobileMenuOpen(false)}>
<Code size={16} weight="fill" />
Developers
</Link>
<a href="https://university.learnhouse.io" target="_blank" rel="noopener noreferrer" className="lh-mobile-drawer-link">
<GraduationCap size={16} weight="fill" />
Learn
<ArrowUpRight size={12} weight="bold" />
</a>
<a href="https://learnhouse.app/integrations" target="_blank" rel="noopener noreferrer" className="lh-mobile-drawer-link">
<Plug size={16} weight="fill" />
Integrations
<ArrowUpRight size={12} weight="bold" />
</a>
<a href="https://learnhouse.app" target="_blank" rel="noopener noreferrer" className="lh-mobile-drawer-link">
<Globe size={16} weight="fill" />
Website
<ArrowUpRight size={12} weight="bold" />
</a>
<a href="https://github.com/learnhouse/learnhouse" target="_blank" rel="noopener noreferrer" className="lh-mobile-drawer-link">
<GithubLogo size={16} weight="fill" />
GitHub
</a>
<a href="https://discord.gg/CMyZjjYZ6x" target="_blank" rel="noopener noreferrer" className="lh-mobile-drawer-link">
<DiscordLogo size={16} weight="fill" />
Discord
</a>
</div>
<div className="lh-mobile-drawer-sidebar" id="mobile-sidebar-mount" />
</div>
</>
)
}
export default Navbar

View File

@@ -0,0 +1,347 @@
'use client'
import { useConfig } from 'nextra-theme-docs'
import { usePathname } from 'next/navigation'
import Link from 'next/link'
import { useState, useEffect } from 'react'
import { createPortal } from 'react-dom'
import {
House,
RocketLaunch,
Lightning,
Cloud,
AppWindow,
BookOpen,
PencilSimple,
Brain,
Users,
Buildings,
GraduationCap,
ChalkboardTeacher,
Stack,
Path,
Cube,
UsersThree,
DownloadSimple,
Gear,
Wrench,
ListChecks,
Terminal,
TreeStructure,
GitBranch,
Plug,
Browser,
Database,
HardDrives,
Key,
Envelope,
Folder,
Lock,
ArrowsClockwise,
ClockCountdown,
ChartBar,
Lifebuoy,
ShieldCheck,
Code,
BookBookmark,
SlidersHorizontal,
ClipboardText,
Trophy,
CheckCircle,
GameController,
ChatCircle,
ChatDots,
ThumbsUp,
Kanban,
ChalkboardSimple,
Microphone,
MagnifyingGlass,
Certificate,
Briefcase,
CreditCard,
Storefront,
ShoppingCart,
Receipt,
IdentificationBadge,
Package,
Scroll,
} from '@phosphor-icons/react/dist/ssr'
const ICON_SIZE = 15
const iconMap = {
// Root level
'/': House,
'/getting-started': RocketLaunch,
'/platform': AppWindow,
'/enterprise': Briefcase,
'/self-hosting': Cloud,
'/developers': Code,
// Getting Started
'/getting-started/quickstart': Lightning,
'/getting-started/cloud-vs-self-hosting': Cloud,
'/getting-started/key-concepts': BookOpen,
// Platform
'/platform/courses': BookBookmark,
'/platform/editor': PencilSimple,
'/platform/ai': Brain,
'/platform/users': Users,
'/platform/organizations': Buildings,
// Platform > Courses
'/platform/courses/chapters-and-activities': Stack,
'/platform/courses/collections': Folder,
'/platform/courses/trails': Path,
// Platform > Editor
'/platform/editor/blocks': Cube,
// Platform > AI
'/platform/ai/for-students': GraduationCap,
'/platform/ai/for-teachers': ChalkboardTeacher,
// Platform > Users
'/platform/users/roles-and-permissions': ShieldCheck,
'/platform/users/authentication': Key,
// Platform > Assignments
'/platform/assignments': ClipboardText,
'/platform/assignments/grading': CheckCircle,
// Platform > Code Execution
'/platform/code-execution': Terminal,
// Platform > Playgrounds
'/platform/playgrounds': GameController,
// Platform > Discussions
'/platform/discussions': ChatCircle,
'/platform/discussions/comments': ChatDots,
// Platform > Boards
'/platform/boards': ChalkboardSimple,
// Platform > Podcasts
'/platform/podcasts': Microphone,
// Platform > Certifications
'/platform/certifications': Certificate,
// Platform > Analytics
'/platform/analytics': ChartBar,
// Platform > Search
'/platform/search': MagnifyingGlass,
// Platform > Payments
'/platform/payments': CreditCard,
'/platform/payments/offers': Storefront,
'/platform/payments/groups': ShoppingCart,
'/platform/payments/enrollments': Receipt,
// Platform > Organizations
'/platform/organizations/multi-tenancy': TreeStructure,
'/platform/organizations/settings': SlidersHorizontal,
// Enterprise
'/enterprise/sso': IdentificationBadge,
'/enterprise/audit-logs': Scroll,
'/enterprise/scorm': Package,
// Self Hosting
'/self-hosting/installation': DownloadSimple,
'/self-hosting/configuration': Gear,
'/self-hosting/maintenance': Wrench,
// Self Hosting > Installation
'/self-hosting/installation/requirements': ListChecks,
'/self-hosting/installation/quick-install': Lightning,
'/self-hosting/installation/cli-reference': Terminal,
// Self Hosting > Configuration
'/self-hosting/configuration/environment-variables': Code,
'/self-hosting/configuration/ai-setup': Brain,
'/self-hosting/configuration/email': Envelope,
'/self-hosting/configuration/storage': HardDrives,
'/self-hosting/configuration/ssl': Lock,
// Self Hosting > Maintenance
'/self-hosting/maintenance/updates': ArrowsClockwise,
'/self-hosting/maintenance/backups': ClockCountdown,
'/self-hosting/maintenance/monitoring': ChartBar,
'/self-hosting/maintenance/troubleshooting': Lifebuoy,
// CLI
'/cli': Terminal,
'/cli/commands': ListChecks,
'/cli/setup-wizard': Lightning,
'/cli/dev-mode': Code,
'/cli/environment-variables': Gear,
// Developers
'/developers/architecture': TreeStructure,
'/developers/contributing': GitBranch,
'/developers/api': Plug,
// Developers > Architecture
'/developers/architecture/frontend': Browser,
'/developers/architecture/backend': Database,
'/developers/architecture/services': HardDrives,
// Developers > Contributing
'/developers/contributing/dev-environment': Terminal,
'/developers/contributing/guidelines': BookOpen,
// Developers > API
'/developers/api/authentication': Key,
'/developers/api/endpoints': Plug,
}
function getIcon(route) {
const Icon = iconMap[route]
if (!Icon) return null
return <Icon size={ICON_SIZE} weight="fill" />
}
function SidebarItem({ item, depth = 0, onNavigate }) {
const pathname = usePathname()
const isActive = pathname === item.route
const hasChildren = item.children && item.children.length > 0
const isChildActive = hasChildren && item.children.some(
child => pathname === child.route || pathname?.startsWith(child.route + '/')
)
const [open, setOpen] = useState(isChildActive || depth < 1)
useEffect(() => {
if (isChildActive) setOpen(true)
}, [isChildActive])
if (item.type === 'separator') {
return (
<div className="lh-sidebar-separator">
{typeof item.title === 'string' ? item.title : item.name}
</div>
)
}
if (item.display === 'hidden') return null
const title = typeof item.title === 'string'
? item.title
: typeof item.title === 'object' && item.title
? item.title
: item.name
const icon = getIcon(item.route)
if (hasChildren) {
return (
<div className="lh-sidebar-folder">
<button
className={`lh-sidebar-folder-btn ${isChildActive ? 'lh-sidebar-folder-active' : ''}`}
onClick={() => setOpen(!open)}
style={{ paddingLeft: 10 }}
>
<span className="lh-sidebar-folder-title">
{icon && <span className="lh-sidebar-icon">{icon}</span>}
{title}
</span>
<svg
className={`lh-sidebar-chevron ${open ? 'lh-sidebar-chevron-open' : ''}`}
width="12"
height="12"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2.5"
strokeLinecap="round"
strokeLinejoin="round"
>
<polyline points="9 18 15 12 9 6" />
</svg>
</button>
{open && (
<div className="lh-sidebar-children">
{item.children.map((child, i) => (
<SidebarItem key={child.route || i} item={child} depth={depth + 1} onNavigate={onNavigate} />
))}
</div>
)}
</div>
)
}
return (
<Link
href={item.route || '#'}
className={`lh-sidebar-link ${isActive ? 'lh-sidebar-link-active' : ''}`}
style={{ paddingLeft: 10 }}
onClick={onNavigate}
>
{icon && <span className="lh-sidebar-icon">{icon}</span>}
{title}
</Link>
)
}
function SidebarContent({ onNavigate }) {
const config = useConfig()
const pathname = usePathname()
const { docsDirectories } = config.normalizePagesResult
const isDevSection = pathname?.startsWith('/developers') || pathname?.startsWith('/self-hosting') || pathname?.startsWith('/cli') || pathname?.startsWith('/enterprise')
const devRoutes = ['/developers', '/self-hosting', '/cli', '/enterprise']
const items = docsDirectories.filter((item) => {
const isDev = devRoutes.some(r => item.route?.startsWith(r))
return isDevSection ? isDev : !isDev
})
// Enforce sidebar order for dev section
const devOrder = ['/developers', '/cli', '/self-hosting', '/enterprise']
items.sort((a, b) => {
const aIdx = devOrder.indexOf(a.route)
const bIdx = devOrder.indexOf(b.route)
if (aIdx !== -1 && bIdx !== -1) return aIdx - bIdx
if (aIdx !== -1) return -1
if (bIdx !== -1) return 1
return 0
})
return (
<nav className="lh-sidebar-nav">
{items.map((item, i) => (
<SidebarItem key={item.route || i} item={item} depth={0} onNavigate={onNavigate} />
))}
</nav>
)
}
function MobileSidebarPortal({ onNavigate }) {
const [mountNode, setMountNode] = useState(null)
useEffect(() => {
const el = document.getElementById('mobile-sidebar-mount')
if (el) setMountNode(el)
}, [])
if (!mountNode) return null
return createPortal(<SidebarContent onNavigate={onNavigate} />, mountNode)
}
export default function Sidebar() {
return (
<>
{/* Desktop sidebar */}
<aside className="lh-sidebar">
<SidebarContent />
</aside>
{/* Portal into mobile drawer */}
<MobileSidebarPortal />
</>
)
}

62
components/TOC/TOC.jsx Normal file
View File

@@ -0,0 +1,62 @@
'use client'
import { useEffect, useState, useRef } from 'react'
export default function TOC({ headings = [] }) {
const [activeId, setActiveId] = useState('')
const observerRef = useRef(null)
useEffect(() => {
if (!headings.length) return
const handleIntersect = (entries) => {
for (const entry of entries) {
if (entry.isIntersecting) {
setActiveId(entry.target.id)
break
}
}
}
observerRef.current = new IntersectionObserver(handleIntersect, {
rootMargin: '-80px 0px -70% 0px',
threshold: 0,
})
for (const h of headings) {
const el = document.getElementById(h.id)
if (el) observerRef.current.observe(el)
}
return () => observerRef.current?.disconnect()
}, [headings])
if (!headings.length) return null
return (
<div className="lh-toc-inner">
<p className="lh-toc-title">On this page</p>
<ul className="lh-toc-list">
{headings.map((heading) => (
<li key={heading.id}>
<a
href={`#${heading.id}`}
className={`lh-toc-link ${heading.depth > 2 ? 'lh-toc-link-nested' : ''} ${activeId === heading.id ? 'lh-toc-link-active' : ''}`}
onClick={(e) => {
e.preventDefault()
const el = document.getElementById(heading.id)
if (el) {
el.scrollIntoView({ behavior: 'smooth', block: 'start' })
setActiveId(heading.id)
history.replaceState(null, '', `#${heading.id}`)
}
}}
>
{typeof heading.value === 'string' ? heading.value : heading.id}
</a>
</li>
))}
</ul>
</div>
)
}

View File

@@ -0,0 +1,29 @@
'use client'
export function Table({ children, ...props }) {
return (
<div className="lh-table-wrap">
<table className="lh-table" {...props}>{children}</table>
</div>
)
}
export function Thead({ children, ...props }) {
return <thead className="lh-table-head" {...props}>{children}</thead>
}
export function Tbody({ children, ...props }) {
return <tbody className="lh-table-body" {...props}>{children}</tbody>
}
export function Tr({ children, ...props }) {
return <tr className="lh-table-row" {...props}>{children}</tr>
}
export function Th({ children, ...props }) {
return <th className="lh-table-th" {...props}>{children}</th>
}
export function Td({ children, ...props }) {
return <td className="lh-table-td" {...props}>{children}</td>
}

View File

@@ -0,0 +1,189 @@
'use client'
import Sidebar from '../Sidebar/Sidebar'
import TOC from '../TOC/TOC'
import { useConfig } from 'nextra-theme-docs'
import { usePathname } from 'next/navigation'
import Link from 'next/link'
import { PencilSimple } from '@phosphor-icons/react/dist/ssr'
function Breadcrumb() {
const config = useConfig()
const { activePath } = config.normalizePagesResult
if (!activePath || activePath.length <= 1) return null
return (
<nav className="lh-breadcrumb" aria-label="breadcrumb">
{activePath.map((item, i) => {
const isLast = i === activePath.length - 1
const title = typeof item.title === 'string' ? item.title : item.name
return (
<span key={item.route || i} className="lh-breadcrumb-item">
{i > 0 && <span className="lh-breadcrumb-sep">/</span>}
{isLast ? (
<span className="lh-breadcrumb-current">{title}</span>
) : (
<Link href={item.route || '#'} className="lh-breadcrumb-link">
{title}
</Link>
)}
</span>
)
})}
</nav>
)
}
function Pagination() {
const config = useConfig()
const { flatDocsDirectories, activeIndex } = config.normalizePagesResult
const prev = activeIndex > 0 ? flatDocsDirectories[activeIndex - 1] : null
const next = activeIndex < flatDocsDirectories.length - 1 ? flatDocsDirectories[activeIndex + 1] : null
if (!prev && !next) return null
return (
<div className="lh-pagination">
{prev ? (
<Link href={prev.route} className="lh-pagination-link lh-pagination-prev">
<span className="lh-pagination-label">Previous</span>
<span className="lh-pagination-title">
{typeof prev.title === 'string' ? prev.title : prev.name}
</span>
</Link>
) : <div />}
{next ? (
<Link href={next.route} className="lh-pagination-link lh-pagination-next">
<span className="lh-pagination-label">Next</span>
<span className="lh-pagination-title">
{typeof next.title === 'string' ? next.title : next.name}
</span>
</Link>
) : <div />}
</div>
)
}
function EditOnGitHub() {
const pathname = usePathname()
let filePath = pathname === '/' ? '/index' : pathname
const gitHubBase = 'https://github.com/learnhouse/docs/edit/main/content'
const href = `${gitHubBase}${filePath}.mdx`
return (
<a
href={href}
target="_blank"
rel="noopener noreferrer"
className="lh-edit-github"
>
<PencilSimple size={13} weight="bold" />
Edit on GitHub
</a>
)
}
function LastEdited({ timestamp }) {
if (!timestamp) return null
const date = new Date(timestamp).toLocaleDateString('en-US', {
month: 'short',
day: 'numeric',
year: 'numeric',
})
return (
<div className="lh-last-edited">
Last edited on {date}
</div>
)
}
function CloudAd() {
return (
<a
href="https://learnhouse.app"
target="_blank"
rel="noopener noreferrer"
className="group block nice-shadow rounded-2xl overflow-hidden bg-white! no-underline! relative transition-transform hover:scale-[1.02]"
>
{/* Dot pattern background */}
<div
className="absolute inset-0 pointer-events-none opacity-40"
style={{
backgroundImage: 'radial-gradient(circle, #a5b4fc 1px, transparent 1px)',
backgroundSize: '14px 14px',
maskImage: 'linear-gradient(to bottom, black 20%, transparent 70%)',
WebkitMaskImage: 'linear-gradient(to bottom, black 20%, transparent 70%)',
}}
/>
<div className="relative p-4">
<div className="flex items-center gap-2.5" style={{ marginBottom: 16 }}>
<img src="/img/logos/learnhouse-dark.svg" alt="LearnHouse" className="h-3.5" />
<span
className="text-[8px] font-bold uppercase tracking-wide text-white! px-1.5 py-px rounded"
style={{
background: 'linear-gradient(180deg, #818cf8 0%, #6366f1 100%)',
boxShadow: 'inset 0 1px 0 rgba(255,255,255,0.25), 0 1px 3px rgba(99,102,241,0.4), 0 0.5px 0 rgba(99,102,241,0.2)',
border: '0.5px solid rgba(99,102,241,0.5)',
textShadow: '0 1px 1px rgba(0,0,0,0.15)',
}}
>
Cloud
</span>
</div>
<p className="text-[12px] font-semibold text-neutral-900! leading-snug m-0!">
Try LearnHouse Cloud
</p>
<p className="mt-1.5 text-[10.5px] text-neutral-400! leading-relaxed m-0!">
Managed hosting with automatic updates, backups, and scaling.
</p>
<div className="mt-3 inline-flex items-center gap-1 text-[10.5px] font-semibold text-indigo-500! group-hover:gap-2 transition-all">
Get started free
<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">
<line x1="5" y1="12" x2="19" y2="12" />
<polyline points="12 5 19 12 12 19" />
</svg>
</div>
</div>
</a>
)
}
export default function Wrapper({ children, toc, metadata }) {
const pathname = usePathname()
const isHome = pathname === '/'
return (
<div className="lh-page">
<Sidebar />
<div className="lh-content-area">
<article className="lh-article">
<div className="lh-article-header">
<Breadcrumb />
{!isHome && <EditOnGitHub />}
</div>
<div className="lh-prose">
{children}
</div>
{!isHome && (
<div className="lh-article-footer">
<LastEdited timestamp={metadata?.timestamp} />
</div>
)}
<Pagination />
</article>
<div className="lh-toc">
{toc && toc.length > 0 && (
<TOC headings={toc} />
)}
<CloudAd />
</div>
</div>
</div>
)
}