Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

Is it possible to redirect the search button to a new page? #170

Closed
Anthonyive opened this issue Apr 16, 2021 · 3 comments
Closed

Is it possible to redirect the search button to a new page? #170

Anthonyive opened this issue Apr 16, 2021 · 3 comments

Comments

@Anthonyive
Copy link

Anthonyive commented Apr 16, 2021

Sorry if the question is dumb since I'm new to Jekyll, but is it possible to redirect the search button to a brand new page and simply display all the search results?

Currently, I have created a page, but the results don't show up when I click the search button. The page only does a live search on the search page, so the results will display as I type, however, if I click the search button or press enter, the results will be cleared.

My current work

Search form and button

<form class="form-inline my-2 my-lg-0" method="POST" action="{{'/search' | prepend: site.baseurl}}">
  <input class="form-control mr-sm-2" type="search" id="search-input" placeholder="Search posts" aria-label="Search">
  <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>

Search results page (/search.md)

---
layout: search
permalink: /search/
---

<div id="search-container">
  <ul id="results-container"></ul>
</div>

_layouts/search.html

---
layout: default
---

<div class="search">

  {{ content }}

  <hr>

  <script src="{{'/node_modules/simple-jekyll-search/dest/simple-jekyll-search.min.js' | prepend: site.baseurl}}"></script>

  <script>
    SimpleJekyllSearch({
    searchInput: document.getElementById('search-input'),
    resultsContainer: document.getElementById('results-container'),
    json: "{{'/search.json' | prepend: site.baseurl}}",
  })
  </script>

</div>
@christian-fei
Copy link
Owner

Hello,

it seems you've already resolved the issue, right?

I am looking at https://anthonyive.github.io/website/ and it does what you want

@Anthonyive
Copy link
Author

Well...yeah. I used a workaround that treats the button as a link and redirects it to another page. Originally, there's a text form and I'm thinking to redirect to another page once I type something in the form then click the search button.

Do you think it's easy to do? Thanks.

@christian-fei
Copy link
Owner

I don't know, I would suggest to do the simplest thing that could possibly work

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants