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

fix search error for no results #111

Merged
merged 1 commit into from
Nov 11, 2024
Merged

Conversation

grmbyrn
Copy link
Collaborator

@grmbyrn grmbyrn commented Nov 8, 2024

Fix for The search box in blog section does not work #108. Search worked when there was a result but when the user entered something in search bar which had no result then searched again nothing would appear when the user searched for something which should return a result.

To prevent this issue, the functions in lib/utils/search.ts ensure that if there is no search term or no matching results, they return default values (like empty arrays or the original text) and properly handle new searches, ensuring the UI remains responsive and updates with results as expected.

export function searchPostsIndex(searchTerm: string) {
    if (!searchTerm) {
	return [];
    }
function replaceTextWithMarker(text: string, match: string) {
    if (!text) {
	return '';
    }

    if (!match) {
	return text;
    }
function getMatches(text: string, searchTerm: string, limit = 1) {
    if (!searchTerm) {
	return [];
    }

@grmbyrn grmbyrn requested a review from josecelano November 8, 2024 17:54
@josecelano
Copy link
Member

ACK b6822db

@josecelano josecelano linked an issue Nov 11, 2024 that may be closed by this pull request
@josecelano josecelano merged commit 3b3aa7e into torrust:develop Nov 11, 2024
1 check passed
da2ce7 pushed a commit to da2ce7/torrust-website that referenced this pull request Nov 21, 2024
…sh date to card, and add GitHub stars

dc22dcf Add contributors routes, add publish date to card, add GitHub stars (grmbyrn)

Pull request description:

  ## Changes Made:

  This pull request introduces several enhancements to our project, focusing on improving the user experience, maintaining code consistency, and providing additional functionality.

  1. Linking to Contributor Pages:
  * Added a link on the `How to Contribute` section of the home page, directing users to a contributor's route.
  * Each contributor's image and name now serve as links, redirecting to individual contributor pages with detailed information.

  2. Enhancing Blog Post Links:
  * Implemented links to each blog post's author, directing users to the respective contributor page.
  * Avoided code repetition and styling inconsistencies by importing the `ContributorCard` component from molecules in components.
  * Added contributor and contributorSlug to the `BlogPost` type in TypeScript to prevent errors as well as to the Front Matter of appropriate Markdown files.

  3. Publication Date in Blog Post Cards:
  * Displayed the publication date beneath each post title in both the `Recent Posts` and `Related Posts` sections.
  * Adopted the "DD/MM/YYYY" format for date representation.
  * Improved user experience by providing context about the blog post's publication date, assuring users that the blog is active.

  4. GitHub Stars in AboutTorrust:
  * Dynamically fetched the number of stars for each Torrust Tracker and Torrust Index repository using the GitHub API.
  * Integrated star counts into the AboutTorrust SvelteKit component to inform users about repository popularity.
  * Added a visually enhancing star icon from the `icons` folder to represent the star count.

  5. RepoURL and RepoName in AboutTorrust:
  * Split repo into repoURL and repoName for better access to the GitHub API and improved user navigation.
  * Ensured that links direct users appropriately to the respective repository.

  These changes collectively enhance the project's functionality, user experience, and maintainability. Please review and merge accordingly. Thank you!

ACKs for top commit:
  josecelano:
    ACK dc22dcf

Tree-SHA512: 2d376f11ac3a991a3de8e46ee5db4691a654048edaab11e8c346058b11a0ea748492789e434a29899adffedd884c35b125c1f23626cf60513f6310c80cbc1feb
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.

The search box in blog section does not work
2 participants