feat: add search

This commit is contained in:
gosangam
2026-05-10 20:41:58 +05:30
parent 4cbb146bc1
commit 09fbcf93ed
9 changed files with 1012 additions and 6 deletions
+31 -1
View File
@@ -287,8 +287,38 @@ export async function getSidebarItems(code: string): Promise<SidebarItem[]> {
}
}
// Hierarchical books (SVA, SSR, DS) — chapters have nested subChapters
const hasHierarchical =
meta.chapters &&
meta.chapters.length > 0 &&
meta.chapters.some((ch) => ch.subChapters && ch.subChapters.length > 0);
if (hasHierarchical && meta.chapters) {
for (const ch of meta.chapters) {
// Parent chapter heading (not navigable on its own)
items.push({
slug: `parent-${ch.number}`,
label: `${ch.number}. ${ch.title}`,
type: "parent",
chapter: ch.number,
parentChapter: ch.number,
});
// Sub-chapters
if (ch.subChapters) {
for (const sub of ch.subChapters) {
items.push({
slug: sub.slug,
label: sub.title,
type: "sub-chapter",
chapter: ch.number,
parentChapter: ch.number,
});
}
}
}
}
// Chapters — if parts exist, group chapters under part headers
if (
else if (
meta.parts &&
meta.parts.length > 0 &&
meta.chapters &&