Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable content searching #62

Merged
merged 34 commits into from
Oct 24, 2024
Merged

enable content searching #62

merged 34 commits into from
Oct 24, 2024

Conversation

rccsousa
Copy link
Collaborator

why:

  • in the current deployment the search bar is a placeholder and has no function which is not working as intented
    how:
  • enables content searching through filtering pre-fetched data that is pulled on the content hub homepage;
  • enables filtering by category by clicking on category pills;
  • includes latest content and highlights as recommendations while content searching is happening;

For the time being Fuse.js is being used as it offers a robust out-of-the-box configurable fuzzy search + weighted search functionality.

Desktop Demo:
https://github.com/user-attachments/assets/e6635f1f-a8c0-4351-8498-c86222c2cfa4

Mobile Demo:
https://github.com/user-attachments/assets/f021fea1-01e4-4f25-b803-41752ef52577

enabling this option will enable the use of the 'use server' flag to use
server actions even on client components
fuse.js is a library that implements customizable fuzzy search
out-of-the-box
- implement options and weighted search
this gives SearchBar initial content to parse instead of re-fetching
data which would be inneficient. SearchBar should only fetch more data
if: 1) there is more data to be retrieved; and b) search yields no
results;
remove unused metadata block
now extends to talks and roundtables and podcasts
further reset button base css
dynamically change component position based on status toggle
no longer needed as data fetching is done by the hub home page and
passed to children components
category pill styling now morphs based on selection state as used in
content filtering
added documentation to the different parts of the file to facilitate
future changes
Copy link

netlify bot commented Oct 24, 2024

Deploy Preview for content-sub ready!

Name Link
🔨 Latest commit 5acc84d
🔍 Latest deploy log https://app.netlify.com/sites/content-sub/deploys/671a7f8d21d3ec0008c0e576
😎 Deploy Preview https://deploy-preview-62--content-sub.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Comment on lines +23 to +24
const categories = await fetchAllContentByType('categories').then((res: Category[]) => res.map((item: Category) => item.title))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pre-fetching categories to feed searchbox and facilitate filtering instead of forcing async on SearchBox component
(also avoids conflicts between use server and use client

Comment on lines +15 to +30
const fuseOptions = {
includeScore: true,
minMatchCharLength: 3,
distance: 1000,
threshold: 0.1,
keys: [
{ name: "content.title", weight: 0.3 },
{ name: "contentType", weight: 0.3 },
{ name: "content.summary", weight: 0.3 },
{ name: "content.authors.name", weight: 0.1 },
{ name: "content.categories.title", weight: 0.8 },
{ name: "content.content.root.children.text", weight: 0.3 },
{ name: "content.content.root.children.children.text", weight: 0.3 },
{ name: "content.content.root.children.children.children.text", weight: 0.3 },
],
};
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a basic implementation of Fuse. i'm giving particular relevante to title and content, but this could be changed

@rccsousa
Copy link
Collaborator Author

@davelange i've found it somewhat difficult to break this component into smaller components given the big number of handlers, which felt it would add redundancy. I've added more extensive documentation to each bit instead.

let me know if it would be better to extend the documentation further or instead break it down into smaller parts

@rccsousa rccsousa marked this pull request as ready for review October 24, 2024 17:05
link generated based on contentType was not being properly converted to
kebab-case
@davelange
Copy link
Contributor

Screenshot 2024-10-24 at 18 51 20

Great work 👏
From a UX perspective, I'm wondering if clicking the suggestions should take me straight to that content's page 🤔
There are some styling issues with rogue scrollbars, but looks good to go

Copy link
Contributor

@davelange davelange left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦭 of approval

@rccsousa
Copy link
Collaborator Author

rccsousa commented Oct 24, 2024

Great work 👏 From a UX perspective, I'm wondering if clicking the suggestions should take me straight to that content's page 🤔 There are some styling issues with rogue scrollbars, but looks good to go

@davelange thanks!
good point. i believe the idea is to suggest queries (google style?) but being clicky links to content could be interesting, autocompleting on click and waiting for rerender could be awkward indeed
i'll check with Joana.

@rccsousa rccsousa merged commit c7b5a60 into main Oct 24, 2024
5 checks passed
@rccsousa rccsousa deleted the rs/enable-content-searching branch October 24, 2024 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants