2023-10-30 04:18:38 +00:00
|
|
|
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)) {
|
2024-10-03 02:47:34 +00:00
|
|
|
if (slug === 'sitemap')
|
|
|
|
continue;
|
2024-10-10 06:50:21 +00:00
|
|
|
if (slug.startsWith('http://')) {
|
|
|
|
elements.push(<>
|
2024-02-13 23:01:07 +00:00
|
|
|
<dt>{info.title}</dt>
|
2024-10-10 06:50:21 +00:00
|
|
|
<dd><Link href={slug}>{slug.substring(7)}</Link></dd>
|
|
|
|
</>);
|
|
|
|
}
|
|
|
|
else if (slug.startsWith('https://')) {
|
|
|
|
elements.push(<>
|
|
|
|
<dt>{info.title}</dt>
|
|
|
|
<dd><Link href={slug}>{slug.substring(8)}</Link></dd>
|
|
|
|
</>);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
const path = `${cwd}/${slug}`;
|
|
|
|
const children = (<><dl style={{marginLeft: '3rem'}}> {traverseMap(info, path, depth + 1)}</dl></>);
|
|
|
|
elements.push(<>
|
|
|
|
<dt>{info.title}</dt>
|
|
|
|
<dd><Link href={path}>paulw.xyz{path}</Link></dd>
|
|
|
|
{children}
|
|
|
|
</>);
|
|
|
|
}
|
2023-10-30 04:18:38 +00:00
|
|
|
}
|
|
|
|
return elements;
|
|
|
|
}
|
|
|
|
|
|
|
|
function SiteMapPage() {
|
|
|
|
|
|
|
|
|
|
|
|
return <Layout>
|
2024-02-13 23:01:07 +00:00
|
|
|
<dl>{traverseMap(SiteMap)}</dl>
|
2023-10-30 04:18:38 +00:00
|
|
|
</Layout>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SiteMapPage;
|
|
|
|
|