Fix broken search on /articles/ (and other list pages)#28
Closed
HeyItsGilbert wants to merge 1 commit into
Closed
Conversation
The client-side search filter threw a TypeError on every card because data-tags is only rendered when an article has tags, but no articles use tags (they use categories). Reading item.dataset.tags returned undefined and calling .includes() on it aborted the filter loop, so search did nothing. Default the dataset reads to empty strings so missing attributes no longer crash the filter. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Px3dibHBwyDeWD2HMwwzoX
✅ Deploy Preview for powershellorg ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Member
Author
|
This only works if all the pages are rendered. Will look into a more comprehensive solution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The search box on
/articles/(and any list page with the same template) did nothing when you typed in it.Root cause
The client-side filter in
themes/powershell-community/layouts/_default/list.htmlthrows aTypeErroron the first card and aborts:data-tagsattribute when the article hastags:tags(they usecategories/authors), sodata-tagsis never rendered..includes()on it:forEachon the first card, so the handler aborts and nothing filters.Fix
Default the dataset reads to empty strings so a missing attribute no longer crashes the filter:
Known remaining limitation (not addressed here)
The filter only loops over
.content-itemelements currently in the DOM, which is just the paginated page (pagerSize: 10). So search only matches within the current page, not across all articles. Fixing that properly would require a real client-side index (e.g. Fuse.js + a generated JSON index) or server-side search — happy to follow up if wanted.🤖 Generated with Claude Code
Generated by Claude Code