master @ 26 LINES
[ HISTORY ] [ UP ]
┌─ TS ───────────────────────────────────────────────────────────────────────┐
│ // REFERENCED BY - pages linking here via wikilinks. Header row plus one │
│ // linked entry per source, indented to the kv value column so the block │
│ // sits flush with SEE ALSO / FILED / TAGS. │
│ import { checkGrid, len } from "../../lib/ascii"; │
│ import type { Backlink } from "../../lib/wikilinks"; │
│ │
│ export interface Props { │
│ refs: Backlink[]; │
│ } │
│ │
│ export const BACKLINKS_LABEL = "REFERENCED BY"; │
│ export const BACKLINKS_INDENT = 12; │
│ │
│ /** Entries with labels truncated (...) to fit after the indent. */ │
│ export function layoutBacklinks(refs: Backlink[], width: number): Backlink[] { │
│ const avail = Math.max(1, width - BACKLINKS_INDENT); │
│ return refs.map((r) => { │
│ const label = │
│ len(r.label) > avail │
│ ? [...r.label].slice(0, avail - 3).join("") + "..." │
│ : r.label; │
│ checkGrid(label, avail, "backlink entry"); │
│ return { url: r.url, label }; │
│ }); │
│ } │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ TS ─────────────────────────────────┐
│ // REFERENCED BY - pages linking here via wi │
│ kilinks. Header row plus one │
│ // linked entry per source, indented to the │
│ kv value column so the block │
│ // sits flush with SEE ALSO / FILED / TAGS. │
│ import { checkGrid, len } from "../../lib/as │
│ cii"; │
│ import type { Backlink } from "../../lib/wik │
│ ilinks"; │
│ │
│ export interface Props { │
│ refs: Backlink[]; │
│ } │
│ │
│ export const BACKLINKS_LABEL = "REFERENCED B │
│ Y"; │
│ export const BACKLINKS_INDENT = 12; │
│ │
│ /** Entries with labels truncated (...) to f │
│ it after the indent. */ │
│ export function layoutBacklinks(refs: Backli │
│ nk[], width: number): Backlink[] { │
│ const avail = Math.max(1, width - BACKLINK │
│ S_INDENT); │
│ return refs.map((r) => { │
│ const label = │
│ len(r.label) > avail │
│ ? [...r.label].slice(0, avail - 3).j │
│ oin("") + "..." │
│ : r.label; │
│ checkGrid(label, avail, "backlink entry" │
│ ); │
│ return { url: r.url, label }; │
│ }); │
│ } │
└──────────────────────────────────────────────┘
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET