Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: posts page logic redesign, add search function (#55)
### Summary This PR refactors the posts page by introducing `PostsClient` to handle client-side rendering logic, and adds robust filtering, search, and pagination features for a better user experience. Additionally, it leverages `es-toolkit` for enhanced efficiency and maintainability, while removing unnecessary code.. ### Key Changes 1. **Styling Adjustments** - Block-quote style refined with max-width, margin, and padding adjustments for improved readability. - Button now has the correct global style with a blue background and pink when hovering. 2. **Posts Page Refactor** - **New `PostsClient` Component**: Extracted client-side logic from the posts page for better modularity. - **Components Added**: Introduced `Pagination` and `SearchInput` components for posts filtering and pagination. - **Category & Tag Param Integration**: Converted categories and tags to URL parameters rather than distinct pages, improving URL structure and navigation. - **Path Update**: Updated `MenuItems` and `ItemLinks` components to reflect new category/tag paths. (Will be refactored in the next PR). 3. **Code Cleanup** - **Suspense Removal**: Removed redundant Suspense wrappers across different pages. - **Export Organization**: Consistently moved all exports to the end of files. 4. **Feature Enhancements** - **Search Functionality**: Implemented a robust search that filters posts by title, abstract, content, tags, and categories, with: - **Dynamic Filter Display**: Category and tag filters only display when the search box is toggled. - **Clear Button**: Users can easily reset the search input. - **Real-Time Updates**: Instant refresh of results as users type for an interactive experience. 5. **Tooling Optimization** - **Array and String Operations**: Replaced local implementations with `es-toolkit` methods across components to simplify array and string operations. - **Pagination Update**: Pagination is disabled if there is only one page, streamlining the UI. 6. **File Deletions & Configuration Updates** - **File Deletions**: Removed redundant category and tag slug pages (`categories/[categorySlug]` and `tags/[tagSlug]`). - **Configuration Update**: Removed unused pinyin and slug definitions from `config.yml` and refined `Category` type to exclude slugs. 7. **Bug Fixes** - Type annotations expanded for better TypeScript support. - Meta generation for `posts/[slug]` page corrected. ### Additional Notes - This refactor streamlines the user experience and prepares the codebase for future scalability. - Improved URL structure and enhanced user interactivity with real-time search contribute to a more intuitive navigation.
- Loading branch information