2023-10-30 00:18:38 -04:00
|
|
|
import Link from 'next/link';
|
|
|
|
import Layout from '../components/layout';
|
2024-12-28 12:23:50 -05:00
|
|
|
import { Sites } from '../lib/site';
|
2023-10-30 00:18:38 -04:00
|
|
|
import SiteMap from '../public/sitemap.json';
|
|
|
|
|
2024-12-28 12:23:50 -05:00
|
|
|
function Desc(props: any) {
|
|
|
|
return (
|
|
|
|
<dl style={props.style}>
|
|
|
|
<dt>{props.term}</dt>
|
|
|
|
<dd>{props.details}</dd>
|
|
|
|
{props.children}
|
|
|
|
</dl>
|
|
|
|
);
|
2023-10-30 00:18:38 -04:00
|
|
|
}
|
|
|
|
|
2024-12-28 12:23:50 -05:00
|
|
|
function traverseMap(head?: Sites, cwd = '', depth = 0) {
|
|
|
|
if (!head) return [];
|
|
|
|
let elements = [];
|
|
|
|
for (const [slug, site] of Object.entries(head)) {
|
|
|
|
if (slug === 'sitemap')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
let details;
|
|
|
|
let list;
|
2023-10-30 00:18:38 -04:00
|
|
|
|
2024-12-28 12:23:50 -05:00
|
|
|
const path = `${cwd}/${slug}`;
|
|
|
|
details = <Link href={path}>paulw.xyz{path}</Link>;
|
|
|
|
list = traverseMap(site.pages, path, depth + 1);
|
2023-10-30 00:18:38 -04:00
|
|
|
|
2024-12-28 12:23:50 -05:00
|
|
|
elements.push(<Desc style={{marginLeft: '3rem'}} key={site.title} term={site.title} details={details}>{list}</Desc>)
|
|
|
|
}
|
|
|
|
return elements;
|
|
|
|
}
|
|
|
|
|
|
|
|
function SiteMapPage() {
|
|
|
|
return <Layout>
|
|
|
|
{traverseMap(SiteMap.pages)}
|
|
|
|
</Layout>;
|
2023-10-30 00:18:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export default SiteMapPage;
|
|
|
|
|