Skip to content

Commit 4451190

Browse files
authored
Merge pull request #73 from afh/mkdocs
Switch to MkDocs and add client-side search and custom 404 page
2 parents a614f00 + d5b6614 commit 4451190

24 files changed

+143
-708
lines changed

.gitignore

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

Gemfile

Lines changed: 0 additions & 10 deletions
This file was deleted.

Gemfile.lock

Lines changed: 0 additions & 123 deletions
This file was deleted.

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ ledger3.texi_repopath := $(OWNER)/$(REPO)/$(LATEST)/doc
1616
ledger.1_repopath := $(OWNER)/$(REPO)/$(LATEST)/doc
1717
ledger-mode.texi_repopath := $(OWNER)/ledger-mode/master/doc
1818

19+
install: source/css
20+
mkdocs build
21+
1922
docs: init sources pdf html
2023

2124
pdf: $(PDF)
@@ -24,6 +27,11 @@ html: $(HTML)
2427

2528
sources: $(SOURCES)
2629

30+
.PHONY: source/css
31+
source/css: custom_theme/sass
32+
python -c 'import sass; sass.compile(dirname=("$<", "$@"))'
33+
34+
2735
.PHONY: init
2836
init:
2937
mkdir -p $(OUTPUT)

config.rb

Lines changed: 0 additions & 12 deletions
This file was deleted.

source/layouts/layout.erb renamed to custom_theme/main.html

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,42 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8">
5-
<title><%= current_page.data.title %></title>
5+
<title>{% if page.title %}{{ page.title }} - {% endif %}{{ config.site_name }}</title>
66
<meta name="description" content="Website and documentation for the open source command-line double-entry accounting system named ledger">
77
<meta name="viewport" content="width=device-width, initial-scale=1">
8-
<%= stylesheet_link_tag "site" %>
8+
<link href="/css/site.css" rel="stylesheet">
99
</head>
1010
<body>
1111
<main>
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>
17-
<ul>
18-
<li><a href="/">ledger</a></li>
19-
<li><a href="index.html">Home</a></li>
20-
<li><a href="features.html">Features</a></li>
21-
<li><a href="docs.html">Docs</a></li>
22-
<li><a href="download.html">Download</a></li>
23-
<li><a href="contribute.html">Contribute</a></li>
24-
<li><a href="https://wiki.ledger-cli.org/">Wiki</a></li>
25-
</ul>
18+
{% if nav|length>1 -%}<ul>
19+
{% for nav_item in nav -%}
20+
<li class="{% if nav_item.active %}current{% endif %}"><a href="{{ nav_item.url|url }}">{{ nav_item.title }}</a></li>
21+
{% endfor -%}
22+
{%- block search_button %}
23+
{%- if 'search' in config['plugins'] %}<li>{%- include "searchbox.html" %}</li>{%- endif %}
24+
{%- endblock %}
25+
</ul>{% endif -%}
2626
</nav>
2727
</header>
2828
<article>
29-
<%= yield %>
29+
{% block content %}
30+
{{ page.content }}
31+
{% endblock %}
3032
</article>
3133
</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 %}
3242
</body>
3343
</html>
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
@import url("darkmode.css");
22

33
html {
4-
background-color:var(--site-background-color);
4+
background:var(--site-background-color);
55
}
66

77
body {
88
color:var(--color);
9-
background-color:var(--background-color);
9+
background:var(--background-color);
1010
}
1111

1212
h1, h2, h3, h4, div.example {
1313
color:var(--color);
1414
}
1515

1616
div.example {
17+
background:var(--example-background-color);
1718
filter:brightness(var(--example-brightness));
18-
background-color:var(--example-background);
1919
}
2020

2121
:link, a[href]:hover {
@@ -25,3 +25,4 @@ div.example {
2525
a[href]:visited {
2626
color:var(--visited-color) !important;
2727
}
28+

source/stylesheets/site.css.scss renamed to custom_theme/sass/site.scss

Lines changed: 17 additions & 4 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; }
@@ -82,9 +95,9 @@ pre, code, tt {
8295
font-family:monospace;
8396
}
8497

85-
pre.highlight {
98+
pre {
8699
margin:0 0 0 1em;
87-
code {
100+
code[class^="language-"] {
88101
padding:0.5em;
89102
display:inline-block;
90103
background:var(--highlight-code-background-color);
@@ -112,7 +125,7 @@ pre.highlight {
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 %}

0 commit comments

Comments
 (0)