Enhanced Search Functionality for Reference Pages
Summary
Implemented a unified search functionality across reference pages, providing consistent behavior and styling for improved content discoverability.
Why Care
This enhancement improves content discoverability across the reference section by providing users with a consistent and intuitive search experience. The implementation ensures that users can quickly find relevant vocabulary terms and concepts across all reference pages.
Implementation
Changes Made
- Enhanced SearchInput component with improved selector logic
- File:
src/components/reference/SearchInput.astro
- Updated search selector to handle both attribute-only and value-based data-searchable elements
- Added support for title and description-specific element searching
- Modified reference pages for consistency
- Files:text
src/pages/more-about/ ├── vocabulary.astro ├── concepts.astro └── index.astro
- Updated data-searchable attributes to use explicit "true" value
- Maintained consistent search behavior across all reference pages
Technical Details
- Search Implementation:typescript
// SearchInput.astro const items = document.querySelectorAll('[data-searchable]:not([data-searchable="false"])');
This selector matches both presence-only and value-based data-searchable attributes while explicitly excluding false values.
Integration Points
- SearchInput component is now used in:
- Reference pages (vocabulary, concepts, index)
- Component styling matches the site's dark theme
- Search behavior is consistent across all implementations
Documentation
- SearchInput Integration:
- Use
data-searchable="true"
on elements that should be searchable - Search looks for content in elements with
data-title
anddata-description
attributes - Falls back to full text content if specific elements aren't found