Skip to content

Commit ff7cdc5

Browse files
authored
Content search (elixir-europe#532)
* testing new search * word fix * no keywords * multiple search fixes * less in config * better css * doc update * relative url search * typo * better scaling * bigger result titles * better css * minify lunr * small changes * stronger drop shadow * no relative url in results
1 parent 8554d10 commit ff7cdc5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+610
-119
lines changed

404.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Page Not Found
3-
search: exclude
3+
search_exclude: true
44
---
55

66
Sorry, but the page you were trying to view does not exist. Try searching for it or looking at the URL to see if it looks correct.

CODE_OF_CONDUCT.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Code of Conduct
33
sidebar: contribute
4-
search: exclude
4+
search_exclude: true
55
toc: false
66
---
77

_config.yml

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ exclude:
3131
- var/
3232
- README.md
3333
- vendor
34+
- Gemfile*
35+
- LICENSE
3436

3537
feedback_subject_line: RDMkit feedback
3638

_includes/contributor-carousel.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{%- assign allcontributors = include.custom | split: ", " | sort %}
55
{%- else %}
66
{%- for page in site.pages %}
7-
{%- if page.contributors and page.search != "exclude" %}
7+
{%- if page.contributors and page.search_exclude != "true" %}
88
{%- assign pagecontr = page.contributors | join: ", " %}
99
{%- if allcontrstr %}
1010
{%- assign allcontrstr = allcontrstr | append: ", " | append: pagecontr %}

_includes/contributor-page.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{%- assign allcontributors = include.custom | split: ", " | sort %}
44
{%- else %}
55
{%- for page in site.pages %}
6-
{%- if page.contributors and page.search != "exclude" %}
6+
{%- if page.contributors and page.search_exclude != "true" %}
77
{%- assign pagecontr = page.contributors | join: ", " %}
88
{%- if allcontrstr %}
99
{%- assign allcontrstr = allcontrstr | append: ", " | append: pagecontr %}

_includes/head.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<meta name="apple-mobile-web-app-title" content="RDMkit">
1010
<meta name="msapplication-TileColor" content="#c23669">
1111
<meta name="theme-color" content="#c23669">
12-
{%- if page.search == "exclude" %}
12+
{%- if page.search_exclude == "true" %}
1313
<meta name="robots" content="noindex" />
1414
{%- endif %}
1515
<title>{%- if page.title %}{{ page.title }} | {{ site.site_title }}{%- else %}{{ site.site_title }}{%- endif %}</title>
@@ -27,6 +27,7 @@
2727
<!-- JavaScript -->
2828
<script src="{{ 'assets/js/popper.min.js' | relative_url }}"></script>
2929
<script src="{{ 'assets/js/jquery-3.5.1.min.js' | relative_url }}"></script>
30+
<script src="{{ 'assets/js/lunr.min.js' | relative_url }}"></script>
3031
<script src="{{ 'assets/js/bootstrap.min.js' | relative_url }}"></script>
3132
<script src="{{ 'assets/js/anchor.min.js' | relative_url }}"></script>
3233
<script src="{{ 'assets/js/toc.js' | relative_url }}"></script>

_includes/topnav.html

+10-21
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@
1414
{%- for entry in topnav.topnav -%}
1515
{%- for item in entry.items -%}
1616
{%- if item.external_url -%}
17-
<li class="nav-item ms-0 ms-lg-3 mt-2 mt-lg-0">
17+
<li class="nav-item ms-0 ms-lg-3">
1818
<a class="nav-link ps-2" href="{{item.external_url}}" target="_blank" rel="noopener">{{item.title}}</a>
1919
</li>
2020
{% elsif page.url contains item.url %}
21-
<li class="nav-item ms-0 ms-lg-3 mt-2 mt-lg-0">
21+
<li class="nav-item ms-0 ms-lg-3">
2222
<a class="nav-link ps-2 active" aria-current="page" href="{{item.url | relative_url }}">{{item.title}}</a>
2323
</li>
2424
{% else %}
25-
<li class="nav-item ms-0 ms-lg-3 mt-2 mt-lg-0">
25+
<li class="nav-item ms-0 ms-lg-3">
2626
<a class="nav-link ps-2" href="{{item.url | relative_url }}">{{item.title}}</a>
2727
</li>
2828
{% endif %}
2929
{%- endfor %}
3030
{%- endfor %}
3131
<!--start Feedback button-->
3232
{%- unless site.feedback_disable %}
33-
<li class="nav-item ms-0 ms-lg-3 mt-2 mt-lg-0">
33+
<li class="nav-item ms-0 ms-lg-3">
3434
{%- if site.feedback_text -%}
3535
{%- assign feedback_text = site.feedback_text -%}
3636
{%- else -%}
@@ -44,23 +44,12 @@
4444
</li>
4545
{% endunless %}
4646
<!--start search-->
47-
<li class="nav-item ms-0 ms-lg-3 mt-2 mt-lg-0">
48-
<form autocomplete="off" class="form-inline">
49-
<input class="form-control" type="text" id="search-input" placeholder="Search..." aria-label="Search">
50-
<ul id="results-container"></ul>
51-
<script src="{{ 'assets/js/simple-jekyll-search.min.js' | relative_url }}"></script>
52-
<script type="text/javascript">
53-
var sjs = SimpleJekyllSearch({
54-
searchInput: document.getElementById('search-input'),
55-
resultsContainer: document.getElementById('results-container'),
56-
json: "{{ 'search.json' | relative_url }}",
57-
searchResultTemplate: '<li><a href="{url}" title="{{page.title | escape }}">{title}</a></li>',
58-
noResultsText: '<li><a href=""">No results found...</a></li>',
59-
limit: 10
60-
})
61-
</script>
62-
63-
</form>
47+
<li class="nav-item ms-0 ms-lg-3">
48+
<div class="search">
49+
<form class="d-flex">
50+
<input type="search" id="search-input" class="search-input form-control" tabindex="0" placeholder="Search {{ site.site_title }}" aria-label="Search {{ site.site_title }}" autocomplete="off">
51+
<div id="search-results" class="search-results"></div>
52+
</div>
6453
</li>
6554
<!--end search-->
6655
</ul>

assets/css/main.css

+89-18
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ pre code {
188188
/*-----Search box top navigation-----*/
189189

190190
#search-input {
191-
width: 15em;
192191
border: 1px solid var(--nav-bg);
193192
}
194193

@@ -197,32 +196,106 @@ pre code {
197196
border-color: var(--primary-theme-color);
198197
}
199198

200-
ul#results-container {
201-
background-color: var(--main-bg-color);
199+
.search {
200+
position: relative;
201+
z-index: 2;
202+
}
203+
204+
.search-results {
202205
position: absolute;
203-
top: 61px;
206+
right: 0;
207+
top: 100%;
208+
display: none;
209+
width: 36em;
210+
max-height: calc(90vh - 200%) !important;
211+
overflow-y: auto;
212+
background-color: var(--white);
213+
box-shadow: 0 1px 2px rgba(0, 0, 0, 20%), 0 3px 10px rgba(0, 0, 0, 15%);
204214
border-radius: 4px;
205-
z-index: 1000;
206-
width: 15em;
207-
padding-left: 0;
208215
}
209216

210-
ul#results-container li {
217+
@media (max-width: 992px) {
218+
.search-results{
219+
width: 100%;
220+
}
221+
}
222+
223+
.search-results ul {
224+
padding-left: 0;
211225
list-style: none;
212226
}
213227

214-
ul#results-container li a {
228+
.search-results a {
229+
display: block;
230+
padding: 0.5rem 0.75rem;
231+
}
232+
233+
.search-results a:hover, .search-results a.active {
234+
background-color: var(--light-grey);
235+
}
236+
237+
.search-result-title {
238+
display: inline-block;
239+
width: 40%;
240+
padding: 0.5rem 0.5rem 0.5rem 0;
241+
vertical-align: top;
242+
}
243+
244+
.search-result-doc {
245+
display: flex;
246+
align-items: center;
247+
word-wrap: break-word;
248+
}
249+
250+
.search-result-doc.search-result-doc-parent {
251+
font-size: 12px !important;
252+
font-weight: 600;
253+
}
254+
255+
.search-result-doc .search-result-doc-title {
256+
overflow: auto;
215257
color: var(--main-text-color);
216-
transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out;
217-
padding: 7px 11px;
218-
text-decoration: none;
258+
}
259+
260+
.search-result-section {
261+
word-wrap: break-word;
262+
color: var(--primary-theme-color)
263+
}
264+
265+
.search-result-rel-url {
219266
display: block;
267+
overflow: hidden;
268+
color: var(--hover-grey);
269+
text-overflow: ellipsis;
270+
white-space: nowrap;
271+
font-size: 10px !important;
220272
}
221273

222-
ul#results-container li a:hover {
223-
color: var(--white-text);
224-
background-color: var(--primary-theme-color);
225-
border-radius: 4px;
274+
.search-result-previews {
275+
display: inline-block;
276+
width: 60%;
277+
padding: 0.5rem 0 0.5rem 0.5rem;
278+
color: var(--hover-grey);
279+
word-wrap: break-word;
280+
border-left: 1px solid var(--light-grey);
281+
font-size: 12px !important;
282+
vertical-align: top;
283+
}
284+
285+
.search-result-preview+.search-result-preview {
286+
margin-top: 0.25rem;
287+
}
288+
289+
.search-result-highlight {
290+
font-weight: bold;
291+
}
292+
293+
.search-no-result {
294+
padding: 0.5rem 0.75rem;
295+
}
296+
297+
.search-active .search-results {
298+
display: block;
226299
}
227300

228301
/*-----Images-----*/
@@ -330,8 +403,6 @@ figcaption {
330403
content: '+';
331404
}
332405

333-
334-
335406
/*-----Summary under page title-----*/
336407

337408
.summary {

assets/js/lunr.min.js

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)