Files
ZacharyZhang-NY 49ed1f8405
CI / crate (push) Failing after 2s
CI / site (push) Successful in 30s
CI / platforms (ubuntu-24.04) (push) Failing after 1m48s
CI / platforms (macos-15-intel) (push) Canceled after 0s
CI / platforms (ubuntu-24.04-arm) (push) Canceled after 0s
CI / platforms (windows-11-arm) (push) Canceled after 0s
CI / platforms (windows-latest) (push) Failing after 15s
Site and gallery: the repo and the showcase catalog live on Gitea at git.zacharyzhang.com
Links, the header's Gitea mark, the catalog's archive download and the showcase pin
workflow (Gitea's API and commit status) move off GitHub; pinned at 6973834, which
restores TokenLedger.
2026-10-09 16:20:32 -04:00

43 lines
1.4 KiB
TypeScript

import manifest from "../../examples/gallery/stories.json";
export interface Story {
title: string;
/** The first component alone, as pages show it. */
name: string;
slug: string;
components: string[];
}
export interface Chapter {
number: number;
slug: string;
title: string;
summary: string;
stories: Story[];
}
export const chapters: Chapter[] = manifest.pages.map((c) => ({
...c,
stories: c.stories.map((s) => ({ ...s, name: s.title.split(/ \/ | · | → | \(/)[0].trim() })),
}));
export const componentCount = new Set(chapters.flatMap((c) => c.stories.flatMap((s) => s.components))).size;
/** Every story in reading order, for paging and search. */
export const all = chapters.flatMap((chapter) => chapter.stories.map((story) => ({ chapter, story })));
/** Chapters by title, else their stories by title or component. */
export function search(query: string): Chapter[] {
const q = query.trim().toLowerCase();
if (!q) return chapters;
return chapters.flatMap((c) => {
if (c.title.toLowerCase().includes(q)) return [c];
const stories = c.stories.filter((s) => s.title.toLowerCase().includes(q) || s.components.some((n) => n.toLowerCase().includes(q)));
return stories.length ? [{ ...c, stories }] : [];
});
}
export const REPO = "https://git.zacharyzhang.com/ZacharyZhang-NY/Ely-GPUI-Components";
export const pad = (n: number) => String(n).padStart(2, "0");