import type { CollectionEntry } from 'astro:content';
import { getAllPosts, postUrl } from '../lib/posts';
import { getActiveProject, getVisibleProjectNavTrees, type ProjectNavNode } from '../lib/projects';
+import { aboutSection, findAboutPath } from '../lib/about';
interface Props {
currentUrl: string;
return !(isCurrent || isAncestor || isSibling || isChild);
}
-// ── About section: static tree matching content/about/ structure ──────────────
-// isNode = true means the page is a section index (has children).
-interface NavPage { url: string; title: string; isNode?: boolean; children?: NavPage[] }
-
-const aboutSection: NavPage = {
- url: '/about.html', title: 'About', isNode: true,
- children: [
- { url: '/contact.html', title: 'Contact' }, // weight 10
- { // weight 10 (alpha: C < I)
- url: '/impressum.html', title: 'Impressum', isNode: true,
- children: [
- { url: '/urheberrechte.html', title: 'Urheberrecht' }, // weight 10
- { url: '/datenschutz.html', title: 'Datenschutz' }, // weight 20
- { url: '/haftung-inhalte.html', title: 'Haftung für Inhalte' }, // weight 30
- { url: '/haftung-links.html', title: 'Haftung für Links' }, // weight 40
- { url: '/google-analytics.html', title: 'Google Analytics' }, // no weight → last
- ]
- },
- { url: '/agb.html', title: 'AGB' }, // weight 30
- ]
-};
-
-// Walk the About tree to find currentUrl — returns parent URL + isNode flag.
-// Replaces the separate aboutParentOf Map and aboutSectionIndexUrls Set.
-function findInTree(node: NavPage, url: string, parentUrl = ''): { parentUrl: string; isNode: boolean } | null {
- if (node.url === url) return { parentUrl, isNode: node.isNode ?? false };
- for (const c of node.children ?? []) {
- const r = findInTree(c, url, node.url);
- if (r) return r;
- }
- return null;
-}
-
-const _currentAbout = findInTree(aboutSection, currentUrl);
-const onAboutSection = _currentAbout !== null;
-const currentAboutParent = _currentAbout?.parentUrl ?? '';
-const currentAboutIsNode = _currentAbout?.isNode ?? false;
+// ── About section: static tree — see src/lib/about.ts ───────────────────────
+const _aboutPath = findAboutPath(aboutSection, currentUrl);
+const onAboutSection = _aboutPath !== null;
+const currentAboutParent = _aboutPath && _aboutPath.length >= 2 ? _aboutPath.at(-2)!.url : '';
+const currentAboutIsNode = _aboutPath ? (_aboutPath.at(-1)!.isNode ?? false) : false;
// Partial application of nodeOff bound to the About subtree's current-page context
const aboutNodeOff = (nodeUrl: string, parentUrl: string, inPath: boolean) =>
--- /dev/null
+export interface NavPage {
+ url: string;
+ title: string;
+ isNode?: boolean;
+ children?: NavPage[];
+}
+
+export const aboutSection: NavPage = {
+ url: '/about.html', title: 'About', isNode: true,
+ children: [
+ { url: '/contact.html', title: 'Contact' }, // weight 10
+ { // weight 10 (alpha: C < I)
+ url: '/impressum.html', title: 'Impressum', isNode: true,
+ children: [
+ { url: '/urheberrechte.html', title: 'Urheberrecht' }, // weight 10
+ { url: '/datenschutz.html', title: 'Datenschutz' }, // weight 20
+ { url: '/haftung-inhalte.html', title: 'Haftung für Inhalte' }, // weight 30
+ { url: '/haftung-links.html', title: 'Haftung für Links' }, // weight 40
+ { url: '/google-analytics.html', title: 'Google Analytics' }, // no weight → last
+ ]
+ },
+ { url: '/agb.html', title: 'AGB' }, // weight 30
+ ]
+};
+
+// Returns path from tree root to the node matching url, or null if not found.
+export function findAboutPath(node: NavPage, url: string): NavPage[] | null {
+ if (node.url === url) return [node];
+ for (const c of node.children ?? []) {
+ const sub = findAboutPath(c, url);
+ if (sub) return [node, ...sub];
+ }
+ return null;
+}
import BaseLayout from '../layouts/BaseLayout.astro';
import Breadcrumb from '../components/Breadcrumb.astro';
import BlogNav from '../components/BlogNav.astro';
+import { aboutSection, findAboutPath } from '../lib/about';
+const _path = findAboutPath(aboutSection, '/about.html')!;
const crumbs = [
{ title: 'Home', url: '/' },
- { title: 'About' },
+ ..._path.slice(0, -1).map(n => ({ title: n.title, url: n.url })),
+ { title: _path.at(-1)!.title },
];
---
import BaseLayout from '../layouts/BaseLayout.astro';
import Breadcrumb from '../components/Breadcrumb.astro';
import BlogNav from '../components/BlogNav.astro';
+import { aboutSection, findAboutPath } from '../lib/about';
+const _path = findAboutPath(aboutSection, '/agb.html')!;
const crumbs = [
{ title: 'Home', url: '/' },
- { title: 'AGB' },
+ ..._path.slice(0, -1).map(n => ({ title: n.title, url: n.url })),
+ { title: _path.at(-1)!.title },
];
---
import BaseLayout from '../layouts/BaseLayout.astro';
import Breadcrumb from '../components/Breadcrumb.astro';
import BlogNav from '../components/BlogNav.astro';
+import { aboutSection, findAboutPath } from '../lib/about';
+const _path = findAboutPath(aboutSection, '/contact.html')!;
const crumbs = [
{ title: 'Home', url: '/' },
- { title: 'Contact' },
+ ..._path.slice(0, -1).map(n => ({ title: n.title, url: n.url })),
+ { title: _path.at(-1)!.title },
];
---
import BaseLayout from '../layouts/BaseLayout.astro';
import Breadcrumb from '../components/Breadcrumb.astro';
import BlogNav from '../components/BlogNav.astro';
+import { aboutSection, findAboutPath } from '../lib/about';
+const _path = findAboutPath(aboutSection, '/datenschutz.html')!;
const crumbs = [
{ title: 'Home', url: '/' },
- { title: 'Datenschutz' },
+ ..._path.slice(0, -1).map(n => ({ title: n.title, url: n.url })),
+ { title: _path.at(-1)!.title },
];
---
import BaseLayout from '../layouts/BaseLayout.astro';
import Breadcrumb from '../components/Breadcrumb.astro';
import BlogNav from '../components/BlogNav.astro';
+import { aboutSection, findAboutPath } from '../lib/about';
+const _path = findAboutPath(aboutSection, '/google-analytics.html')!;
const crumbs = [
{ title: 'Home', url: '/' },
- { title: 'Impressum', url: '/impressum.html' },
- { title: 'Google Analytics' },
+ ..._path.slice(0, -1).map(n => ({ title: n.title, url: n.url })),
+ { title: _path.at(-1)!.title },
];
---
import BaseLayout from '../layouts/BaseLayout.astro';
import Breadcrumb from '../components/Breadcrumb.astro';
import BlogNav from '../components/BlogNav.astro';
+import { aboutSection, findAboutPath } from '../lib/about';
+const _path = findAboutPath(aboutSection, '/haftung-inhalte.html')!;
const crumbs = [
{ title: 'Home', url: '/' },
- { title: 'Impressum', url: '/impressum.html' },
- { title: 'Haftung für Inhalte' },
+ ..._path.slice(0, -1).map(n => ({ title: n.title, url: n.url })),
+ { title: _path.at(-1)!.title },
];
---
import BaseLayout from '../layouts/BaseLayout.astro';
import Breadcrumb from '../components/Breadcrumb.astro';
import BlogNav from '../components/BlogNav.astro';
+import { aboutSection, findAboutPath } from '../lib/about';
+const _path = findAboutPath(aboutSection, '/haftung-links.html')!;
const crumbs = [
{ title: 'Home', url: '/' },
- { title: 'Impressum', url: '/impressum.html' },
- { title: 'Haftung für Links' },
+ ..._path.slice(0, -1).map(n => ({ title: n.title, url: n.url })),
+ { title: _path.at(-1)!.title },
];
---
import BaseLayout from '../layouts/BaseLayout.astro';
import Breadcrumb from '../components/Breadcrumb.astro';
import BlogNav from '../components/BlogNav.astro';
+import { aboutSection, findAboutPath } from '../lib/about';
+const _path = findAboutPath(aboutSection, '/impressum.html')!;
const crumbs = [
{ title: 'Home', url: '/' },
- { title: 'Impressum' },
+ ..._path.slice(0, -1).map(n => ({ title: n.title, url: n.url })),
+ { title: _path.at(-1)!.title },
];
---
import BaseLayout from '../layouts/BaseLayout.astro';
import Breadcrumb from '../components/Breadcrumb.astro';
import BlogNav from '../components/BlogNav.astro';
+import { aboutSection, findAboutPath } from '../lib/about';
+const _path = findAboutPath(aboutSection, '/urheberrechte.html')!;
const crumbs = [
{ title: 'Home', url: '/' },
- { title: 'Impressum', url: '/impressum.html' },
- { title: 'Urheberrecht' },
+ ..._path.slice(0, -1).map(n => ({ title: n.title, url: n.url })),
+ { title: _path.at(-1)!.title },
];
---