Skip to content

Commit b6179e9

Browse files
committed
Add client-side search
1 parent 9117d77 commit b6179e9

File tree

7 files changed

+64
-25
lines changed

7 files changed

+64
-25
lines changed

.gitignore

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
1-
build
2-
# source/css is generated from custom_theme/sass
1+
# NOTA BENE: source/css is generated from custom_theme/sass
32
source/css
4-
*.hi
5-
*.o
6-
*.html
7-
site
8-
_*
9-
*.org
10-
snapshot.tar.gz
11-
*.log
12-
*.aes
13-
.DS_Store
3+
# Files generated during build or development
4+
build
145
result*
15-
vendor/
16-
.bundle/
6+
# Files specific to macOS
7+
.DS_Store

custom_theme/main.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,32 @@
1212
<aside>
1313
<a href="https://git.ledger-cli.org/ledger" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><title>Fork me on GitHub</title><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>
1414
</aside>
15+
1516
<header>
1617
<nav>
1718
{% if nav|length>1 -%}<ul>
1819
{% for nav_item in nav -%}
1920
<li class="{% if nav_item.active %}current{% endif %}"><a href="{{ nav_item.url|url }}">{{ nav_item.title }}</a></li>
2021
{% endfor -%}
22+
{%- block search_button %}
23+
{%- if 'search' in config['plugins'] %}<li>{%- include "searchbox.html" %}</li>{%- endif %}
24+
{%- endblock %}
2125
</ul>{% endif -%}
2226
</nav>
2327
</header>
2428
<article>
25-
{{ page.content }}
29+
{% block content %}
30+
{{ page.content }}
31+
{% endblock %}
2632
</article>
2733
</main>
34+
{%- block scripts %}
35+
<script>var base_url = '{{ base_url }}';</script>
36+
<script src="{{ 'js/theme_extra.js'|url }}" defer></script>
37+
<script src="{{ 'js/theme.js'|url }}" defer></script>
38+
{%- for path in extra_javascript %}
39+
<script src="{{ path }}" defer></script>
40+
{%- endfor %}
41+
{%- endblock %}
2842
</body>
2943
</html>

custom_theme/sass/site.scss

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
@import url("darkmode.css");
22

3+
.current {
4+
font-weight: bold;
5+
}
6+
7+
div[role=search] {
8+
display: inline-block;
9+
position:absolute;
10+
margin-top: -1em;
11+
* {
12+
display: inline-block;
13+
}
14+
}
15+
316
body {
417
color:var(--color);
518
background:var(--background-color);
@@ -20,7 +33,7 @@ header {
2033

2134
li {
2235
display:inline-block;
23-
margin:0 2em 0 0;
36+
margin:0 1.75em 0 0;
2437
}
2538

2639
a { text-decoration:none; }
@@ -112,7 +125,7 @@ pre {
112125

113126
@media screen and (max-width:765px) {
114127
header li {
115-
margin:1em 2em 0 0;
128+
margin:1em 1.75em 0 0;
116129
}
117130
nav li:has(a[href="/"]) {
118131
display:block;

custom_theme/search.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{% extends "main.html" %}
2+
3+
{% block content %}
4+
5+
<h1 id="search">{% trans %}Search Results{% endtrans %}</h1>
6+
7+
<form id="content_search" action="search.html">
8+
<span role="status" aria-live="polite" class="ui-helper-hidden-accessible"></span>
9+
<input name="q" id="mkdocs-search-query" type="text" class="search_input search-query ui-autocomplete-input" placeholder="{% trans %}Search the Docs{% endtrans %}" autocomplete="off" autofocus title="{% trans %}Type search term here{% endtrans %}">
10+
</form>
11+
12+
<div id="mkdocs-search-results" class="search-results" data-no-results-text="{% trans %}No results found{% endtrans %}">
13+
</div>
14+
15+
{% endblock %}

custom_theme/searchbox.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div role="search">
2+
<form id ="rtd-search-form" class="wy-form" action="{{ base_url }}/search.html" method="get">
3+
<input type="text" name="q" placeholder="{% trans %}Search{% endtrans %}" title="{% trans %}Type search term here{% endtrans %}" />
4+
</form>
5+
</div>

mkdocs.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@ site_name: ledger
22
site_url: https://ledger-cli.org
33
site_dir: build
44
repo_url: https://github.com/ledger/ledger.github.com/
5-
theme: readthedocs
65
docs_dir: source
76
use_directory_urls: false
87

98
theme:
109
name: null
1110
custom_dir: 'custom_theme/'
11+
include_search_page: true
12+
search_index_only: false
1213

1314
nav:
1415
- ledger: /
15-
- Home: index.md
16-
- Features: features.md
17-
- Docs: docs.md
18-
- Download: download.md
19-
- Contribute: contribute.md
16+
- Home: /index.html
17+
- Features: /features.html
18+
- Docs: /docs.html
19+
- Download: /download.html
20+
- Contribute: /contribute.html
2021
- Wiki: https://wiki.ledger-cli.org

source/404.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ title: Not Found
55
# Page not found
66

77
Unfortunately the page you are looking for cannot be found.
8-
98
Possibly the page moved to another location, or the link or URL was mistyped.
109

11-
Please use the navigation above to browse other content available on this website.
10+
To find what you were looking for please use the [search](/search.html) above
11+
or the navigation on the top of the page to browse other content available on this website.
1212

1313
If you believe there really should be a page under this URL please
1414
[create an issue](https://git.ledger-cli.org/ledger.github.io/issues/new).

0 commit comments

Comments
 (0)