(pages: Page[], library: Library, searchValue: string)
| 300 | * Hook to build and manage sections for a library with search filtering. |
| 301 | */ |
| 302 | export function useLibrarySections(pages: Page[], library: Library, searchValue: string) { |
| 303 | const sections = useMemo(() => buildSectionsFromPages(pages, library), [pages, library]); |
| 304 | |
| 305 | const filteredSections = useMemo( |
| 306 | () => filterSections(sections, searchValue), |
| 307 | [sections, searchValue] |
| 308 | ); |
| 309 | |
| 310 | const getSectionNames = useCallback(() => { |
| 311 | return sections.map(s => s.name); |
| 312 | }, [sections]); |
| 313 | |
| 314 | return {sections, filteredSections, getSectionNames}; |
| 315 | } |
| 316 | |
| 317 | /** |
| 318 | * Creates search options for filtering/sorting Page objects directly. |
no test coverage detected