feat: added a twist

This commit is contained in:
2026-04-01 00:53:55 +02:00
parent 0b7deee59e
commit b40c6436cd
76 changed files with 15121 additions and 64 deletions

View File

@@ -0,0 +1,21 @@
import { useMemo } from "react";
import { useGraph } from "@/hooks/useGraph";
export interface BacklinkPage {
name: string;
title: string | null;
}
export function useBacklinks(currentSlug: string | undefined): BacklinkPage[] {
const { data } = useGraph();
return useMemo(() => {
if (!data || !currentSlug) return [];
const nodeMap = new Map(data.nodes.map((n) => [n.id, n]));
return data.edges
.filter((e) => e.target === currentSlug)
.map((e) => ({
name: e.source,
title: nodeMap.get(e.source)?.title ?? null,
}));
}, [data, currentSlug]);
}