mirror of
https://github.com/lissy93/networking-toolbox.git
synced 2026-11-26 07:33:23 +03:00
Updated sitemap with about pages, and added a page-listing route
This commit is contained in:
1 parent
7c36d5d3d4
commit
e6f2f096fd
2 files changed
+164
-1
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { ALL_PAGES, TOP_NAV, footerLinks } from '$lib/constants/nav';
|
||||
import { ALL_PAGES, TOP_NAV, footerLinks, aboutPages } from '$lib/constants/nav';
|
||||
import { site } from '$lib/constants/site';
|
||||
|
||||
/**
|
||||
@@ -20,6 +20,9 @@ export async function GET() {
|
||||
// Add all pages from the navigation structure
|
||||
ALL_PAGES.forEach(item => urls.add(item.href));
|
||||
|
||||
// Add about pages
|
||||
aboutPages.forEach(item => urls.add(item.href));
|
||||
|
||||
// Add footer pages (about, etc.)
|
||||
footerLinks.forEach(item => {
|
||||
// Only include internal links (not external GitHub, etc.)
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
<script lang="ts">
|
||||
import { TOP_NAV, aboutPages, SUB_NAV } from '$lib/constants/nav';
|
||||
|
||||
interface TreeNode {
|
||||
label: string;
|
||||
href: string | null;
|
||||
description?: string;
|
||||
children: TreeNode[];
|
||||
}
|
||||
|
||||
const mapToNode = (item: any): TreeNode => ({
|
||||
label: item.label || item.title,
|
||||
href: item.href || null,
|
||||
description: item.description,
|
||||
children: []
|
||||
});
|
||||
|
||||
// Build tree structure from navigation data
|
||||
const siteTree: TreeNode[] = [
|
||||
...TOP_NAV.map(topItem => {
|
||||
const section = mapToNode(topItem);
|
||||
const subNavData = SUB_NAV[topItem.href];
|
||||
|
||||
if (subNavData) {
|
||||
section.children = subNavData.map(item =>
|
||||
'href' in item
|
||||
? mapToNode(item)
|
||||
: { ...mapToNode(item), children: item.items.map(mapToNode) }
|
||||
);
|
||||
}
|
||||
return section;
|
||||
}),
|
||||
...(aboutPages.length ? [{
|
||||
label: 'About',
|
||||
href: null,
|
||||
description: 'Information about the project and documentation',
|
||||
children: aboutPages.map(mapToNode)
|
||||
}] : [])
|
||||
];
|
||||
</script>
|
||||
|
||||
{#snippet nodeLink(node: TreeNode)}
|
||||
{@const title = node.description || node.label}
|
||||
{@const ariaLabel = node.description ? `${node.label}: ${node.description}` : node.label}
|
||||
{#if node.href}
|
||||
<a href={node.href} {title} aria-label={ariaLabel}>{node.label}</a>
|
||||
{:else}
|
||||
<span class={node.children.length ? 'section-title' : 'group-title'} {title} aria-label={ariaLabel}>
|
||||
{node.label}
|
||||
</span>
|
||||
{/if}
|
||||
{/snippet}
|
||||
|
||||
{#snippet treeNode(node: TreeNode, level = 0)}
|
||||
{#if node.children.length > 0}
|
||||
<details open>
|
||||
<summary>{@render nodeLink(node)}</summary>
|
||||
<ul>
|
||||
{#each node.children as child}
|
||||
<li>
|
||||
{#if child.children.length > 0}
|
||||
{@render treeNode(child, level + 1)}
|
||||
{:else}
|
||||
{@render nodeLink(child)}
|
||||
{/if}
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</details>
|
||||
{:else}
|
||||
{@render nodeLink(node)}
|
||||
{/if}
|
||||
{/snippet}
|
||||
|
||||
<div class="sitemap-page card">
|
||||
<h1>Site Map</h1>
|
||||
<p>
|
||||
Site-wide page listing.<br>
|
||||
For computer-readable version,
|
||||
see <a class="xml-link" href="/sitemap.xml">sitemap.xml</a>
|
||||
</p>
|
||||
|
||||
<div class="tree">
|
||||
{#each siteTree as node}
|
||||
{@render treeNode(node)}
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
.sitemap-page {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
padding: var(--spacing-lg);
|
||||
h1 {
|
||||
margin-bottom: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.xml-link {
|
||||
color: var(--color-primary);
|
||||
background: var(--bg-primary);
|
||||
border-radius: var(--radius-sm);
|
||||
padding: var(--spacing-2xs) var(--spacing-sm);
|
||||
}
|
||||
}
|
||||
|
||||
.tree {
|
||||
details {
|
||||
margin: var(--spacing-xs) 0;
|
||||
|
||||
&[open] > summary {
|
||||
margin-bottom: var(--spacing-xs);
|
||||
}
|
||||
|
||||
summary {
|
||||
cursor: pointer;
|
||||
padding: var(--spacing-xs);
|
||||
border-radius: var(--border-radius);
|
||||
transition: background-color 0.2s;
|
||||
color: var(--color-primary);
|
||||
font-weight: bold;
|
||||
&:hover {
|
||||
background: color-mix(in srgb, var(--color-accent), transparent 90%);
|
||||
}
|
||||
&::marker {
|
||||
color: var(--color-primary-hover);
|
||||
}
|
||||
}
|
||||
|
||||
ul {
|
||||
list-style: none;
|
||||
padding-left: var(--spacing-md);
|
||||
margin: var(--spacing-xs) 0;
|
||||
|
||||
li {
|
||||
margin: var(--spacing-xs) 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--color-link);
|
||||
text-decoration: none;
|
||||
padding: 0 var(--spacing-sm);
|
||||
display: inline-block;
|
||||
transition: all 0.2s;
|
||||
border-radius: var(--radius-sm);
|
||||
|
||||
&:hover {
|
||||
background: color-mix(in srgb, var(--color-primary), transparent 95%);
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
.section-title,
|
||||
.group-title {
|
||||
color: var(--color-primary);
|
||||
font-weight: 400;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user