- Run record
- loading
Loading this Run…
Loading the Revisions of this Run…
A published source file of Revision 0 of Boardly — Website Relaunch 1.0.0, shown as text in the browser.
import boardFile from "../public/data/board.json";
import membersFile from "../public/data/members.json";
import type { BoardFile, BoardState, Card, Member, MembersFile } from "./types";
export const boardData = boardFile as BoardFile;
export const members: Member[] = (membersFile as MembersFile).members;
export const memberById: Record<string, Member> = Object.fromEntries(
members.map((m) => [m.id, m]),
);
export const labelById = Object.fromEntries(boardData.labels.map((l) => [l.id, l]));
export const TODAY = boardData.today;
export function initialState(): BoardState {
const cards: Record<string, Card> = {};
for (const c of boardData.cards) {
cards[c.id] = {
...c,
labels: [...c.labels],
checklist: c.checklist.map((i) => ({ ...i })),
};
}
return {
columns: boardData.columns.map((col) => ({ ...col, card_ids: [...col.card_ids] })),
cards,
};
}
/* ---------- dates ---------- */
const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
export function formatDue(iso: string, long = false): string {
const [y, m, d] = iso.split("-").map(Number);
const month = MONTHS[m - 1] ?? "";
if (long) return `${d} ${month} ${y}`;
return `${d} ${month}`;
}
/** Overdue when strictly before today (ISO strings compare lexically). */
export function isOverdue(card: Card, columnId: string): boolean {
return card.due !== null && card.due < TODAY && columnId !== "done";
}
export function daysFromToday(iso: string): number {
const a = Date.UTC(+iso.slice(0, 4), +iso.slice(5, 7) - 1, +iso.slice(8, 10));
const b = Date.UTC(+TODAY.slice(0, 4), +TODAY.slice(5, 7) - 1, +TODAY.slice(8, 10));
return Math.round((a - b) / 86400000);
}
/* ---------- people ---------- */
export function initials(name: string): string {
return name
.split(/\s+/)
.filter(Boolean)
.slice(0, 2)
.map((p) => p[0]!.toUpperCase())
.join("");
}
export function memberName(id: string | null): string {
if (!id) return "Unassigned";
return memberById[id]?.name ?? id;
}Source is browser-viewable only. There is no download or archive endpoint, and no additional license is granted beyond inspection and research.