Skip to content

Add search functionality to docs #128

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

Merged
merged 1 commit into from
Feb 11, 2017
Merged
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
1 change: 1 addition & 0 deletions docs/_includes/docs_menu.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div class="well docs-menu col-xs-12 col-sm-4 col-md-3">
{% include search_form.html %}
<ul class="nav nav-list">
<li>
<a href="{{ site.baseurl }}/docs">Get Started</a>
Expand Down
1 change: 1 addition & 0 deletions docs/_includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<link rel="stylesheet" href="{{ site.baseurl }}/css/main.css">
<link rel="stylesheet" href="{{ site.baseurl }}/css/github-highlight.css">

<script src="{{ site.baseurl }}/js/redirect-to-search.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
7 changes: 7 additions & 0 deletions docs/_includes/search_form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="search-container form-group has-feedback">
<form id="docs-search">
<input type="search" id="search-input" class="custom-search form-control" placeholder="Search the docs..." search-url="{{ site.baseurl}}/docs/search.html">
<span class="glyphicon glyphicon-search form-control-feedback"></span>
</form>
</div>

43 changes: 43 additions & 0 deletions docs/_layouts/search.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
layout: search
---

<!DOCTYPE html>
<html>

<head>
{% include head.html %}
<script type="text/javascript">
var search_blob = {
{% for page in site.pages %}
{% if page.indexed_by_search != false %}
"{{ site.baseurl }}{{ page.url }}": {
"title": {{ page.title | escape | jsonify }},
"content": {{ page.content | remove_first: '* TOC' | replace_first:':toc',':class="blank"' | markdownify | strip_html | normalize_whitespace | jsonify }}
}{% unless forloop.last %},{% endunless %}
{% endif %}
{% endfor %}
};
</script>

<script src="{{ site.baseurl }}/js/lunr.min.js"></script>
<script src="{{ site.baseurl }}/js/search.js"></script>
</head>

<body>
<div class="container">
{% include header.html %}
{% include docs_menu.html %}

<div class="content .col-xs-12 .col-sm-8 .col-md-9">
<h1 id="searchHeading"></h1>
<br />
<div id="searchResultsContainer">
<p>Loading search results...</p>
</div>

{% include footer.html %}
</div>
</div>
</body>
</html>
5 changes: 5 additions & 0 deletions docs/docs/search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Search
layout: search
---

6 changes: 6 additions & 0 deletions docs/js/lunr.min.js

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

13 changes: 13 additions & 0 deletions docs/js/redirect-to-search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(function () {
window.addEventListener('load', function () {
var search_form = document.getElementById('docs-search');
var search_input = document.getElementById('search-input');

if (search_form) {
search_form.addEventListener('submit', function (e) {
e.preventDefault();
window.location.href = search_input.getAttribute('search-url') + '?q=' + encodeURIComponent(search_input.value);
});
}
});
})();
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy