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

Search queries as links for filtered listings #6755

Open
dragonstyle opened this issue Sep 7, 2023 Discussed in #6696 · 6 comments
Open

Search queries as links for filtered listings #6755

dragonstyle opened this issue Sep 7, 2023 Discussed in #6696 · 6 comments
Labels
enhancement New feature or request listings search
Milestone

Comments

@dragonstyle
Copy link
Collaborator

Discussed in #6696

Originally posted by bambirombi September 4, 2023

Description

Take as an example this blog: https://mine-cetinkaya-rundel.github.io/quarto-tip-a-day/

When I put, a term in the filter-ui it gives me the results that match the term. For example, when I put access it gives 5 posts as a result.

What I want is to have that in form of a link (a search query), so you can see exactly those same results when clicking the link. Something as this https://mine-cetinkaya-rundel.github.io/quarto-tip-a-day/search?q=access but that actually work

@dragonstyle dragonstyle added the enhancement New feature or request label Sep 7, 2023
@dragonstyle dragonstyle self-assigned this Sep 7, 2023
@dragonstyle dragonstyle added this to the v1.4 milestone Sep 19, 2023
@dragonstyle dragonstyle modified the milestones: v1.4, v1.5 Dec 1, 2023
@dragonstyle dragonstyle modified the milestones: v1.5, Future Feb 22, 2024
@e-kotov
Copy link

e-kotov commented Sep 4, 2024

@dragonstyle

you can try embedding this script into your page

document.addEventListener("DOMContentLoaded", function() {
  // Get the URL parameters
  const params = new URLSearchParams(window.location.search);

  // Check if the "filter" parameter exists
  if (params.has("filter")) {
    // Get the value of the "filter" parameter
    const filterValue = params.get("filter");

    // Find the filter input element
    const filterInput = document.querySelector("input.search.form-control");

    // Ensure the input element is found
    if (filterInput) {
      // Set the filter input value
      filterInput.value = filterValue;

      // Trigger both 'input' and 'keyup' events to activate filtering
      const inputEvent = new Event('input', {
        bubbles: true,
        cancelable: true,
      });
      filterInput.dispatchEvent(inputEvent);

      // Simulate a keyup event to trigger the filtering
      const keyupEvent = new KeyboardEvent('keyup', {
        bubbles: true,
        cancelable: true,
        key: 'Enter', // simulate Enter key press
      });
      filterInput.dispatchEvent(keyupEvent);
    }
  }
});

after that you should be able to link like so:
https://mine-cetinkaya-rundel.github.io/quarto-tip-a-day/index.html?filter=access

@dragonstyle on a related question, do you know why in your filter any letter case works (both upper and lower), but here https://albert-rapp.de/blog searching for "An" gives nothing while searching for "an" returns results?

@dragonstyle
Copy link
Collaborator Author

Thanks! I don't know why, but on that particular blog, the find appears to never match anything that isn't lowercase (any uppercase letters don't match for me). Without looking more closely at the source code, it's hard for me to say exactly why.

@mcanouil
Copy link
Collaborator

mcanouil commented Sep 4, 2024

I believe this to be more widespread than this blog.

See https://m.canouil.dev/quarto-extensions/

@e-kotov
Copy link

e-kotov commented Sep 4, 2024

I believe this to be more widespread than this blog.

See https://m.canouil.dev/quarto-extensions/

yes, I only used that blog as an example. In fact I am having this issue with all my quarto websites...

My own public example is here:
https://github.com/e-kotov/mitma-data-issues

@dragonstyle
Copy link
Collaborator Author

I think this must be an issue introduced perhaps in a new release of Quarto? I don't see it in some older versions like:

https://web.archive.org/web/20230329074857/https://quarto.org/docs/extensions/

I think it is worth opening a new issue to track this.

@mcanouil
Copy link
Collaborator

@dragonstyle on a related question, do you know why in your filter any letter case works (both upper and lower), but here https://albert-rapp.de/blog searching for "An" gives nothing while searching for "an" returns results?

This has been fixed in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request listings search
Projects
None yet
Development

No branches or pull requests

3 participants