T45d Site · Components: one search over chapters, stories and components (Slash, Enter, Escape), the index in hairline rows, the story beside a sticky chapter rail, arrows between stories
This commit is contained in:
1 parent
9ea811d4e8
commit
8712fd0389
5 files changed
+173
-48
No files matched your search
@@ -21,6 +21,17 @@ export const componentCount = new Set(chapters.flatMap((c) => c.stories.flatMap(
|
||||
/** 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://github.com/ZacharyZhang-NY/Ely-GPUI-Components";
|
||||
|
||||
export const pad = (n: number) => String(n).padStart(2, "0");
|
||||
Reference in new issue
Block a user