import Link from 'next/link'; import Layout from '../components/layout'; import { Site } from '../lib/site'; import SiteMap from '../public/sitemap.json'; function traverseMap(head: Site, cwd = '', depth = 0) { if (head.subpages === undefined) return []; let elements = []; for (const [slug, info] of Object.entries(head.subpages)) { if (slug === 'sitemap') continue; if (slug.startsWith('http://')) { elements.push(<>
{info.title}
{slug.substring(7)}
); } else if (slug.startsWith('https://')) { elements.push(<>
{info.title}
{slug.substring(8)}
); } else { const path = `${cwd}/${slug}`; const children = (<>
{traverseMap(info, path, depth + 1)}
); elements.push(<>
{info.title}
paulw.xyz{path}
{children} ); } } return elements; } function SiteMapPage() { return
{traverseMap(SiteMap)}
; } export default SiteMapPage;