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

[ELY-2394] Add the ability to search for blog posts on the Elytron Blogs Page #2055

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions _includes/search.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- Html Elements for Search -->
<div id="search-container" class="grid__item">

<input type="text" id="search-input" class="search-input" placeholder="Search...">

<ul id="results-container" class="search-result"></ul>

</div>

<!-- Script pointing to search-script.js -->
<script src="{{ '/assets/javascript/search-script.js' | relative_url }}" type="text/javascript"></script>

<!-- Configuration -->
<script>
SimpleJekyllSearch({
searchInput: document.getElementById('search-input'),
resultsContainer: document.getElementById('results-container'),
json: '{{ "" | prepend: site.baseurl | append: "/search.json" }}'
})
</script>
4 changes: 4 additions & 0 deletions _layouts/blog.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
---
layout: default
---

<div class="blog-page grid-wrapper">

<div class="grid__item width-12-12"></div>

<div class="grid__item width-1-12 align-self-center"></div>

<div class="grid__item width-8-12 width-12-12-m">

{% include search.html %}

{% for post in paginator.posts %}
{% assign author = site.data.authors[post.author] %}
<div class="blog-list-item grid-wrapper">
Expand Down
15 changes: 15 additions & 0 deletions _sass/layouts/search.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.search-input {
color: #000000;
font-family: "Titillium Web", sans-serif;
width: 100%;
}

ul.search-result {
margin-top: 0;
background: #fff;
position: absolute;
background-color: #DCDCDC;
list-style-type: none;
list-style-position: unset;
min-width: 50%;
}
1 change: 1 addition & 0 deletions assets/css/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@import "main";
@import "core/grid";
@import "core/asciidoc";
@import "layouts/search";
@import "layouts/blog";
@import "layouts/guides";
@import "layouts/community";
Expand Down
6 changes: 6 additions & 0 deletions assets/javascript/search-script.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions search.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
---
[
{% for post in site.posts %}
{

"title" : "{{ post.title | escape }}",
{% if post.link %}
"url" : "{{ post.link }}",
{% else %}
"url" : "{{ site.baseurl }}{{ post.url }}",
{% endif %}
"category" : "{{ post.synopsis }}",
"tags" : "{{ post.tags | join: ', ' }}",
"date" : "{{ post.date }}"

} {% unless forloop.last %},{% endunless %}
{% endfor %}
]