Added ArticleFooter and SequenceNav

This commit is contained in:
2026-09-30 12:50:56 +02:00
parent 90b5390795
commit 8ef3899782
20 changed files with 485 additions and 4 deletions

View File

@@ -1,5 +1,30 @@
import type { Article } from './types'
export type Sequence = {
parent: Article
siblings: Article[]
position: number
previous: Article | null
next: Article | null
}
export function sequenceOf(article: Article): Sequence | null {
const parent = article.parent
if (!parent?.route.sequence) return null
const siblings = parent.children
const position = siblings.indexOf(article)
if (position === -1 || siblings.length < 2) return null
return {
parent,
siblings,
position,
previous: siblings[position - 1] ?? null,
next: siblings[position + 1] ?? null,
}
}
export function trailOf(article: Article): Article[] {
const trail: Article[] = []
for (let node: Article | null = article; node; node = node.parent) trail.unshift(node)