summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Langford <wlangfor@gmail.com>2020-03-02 10:55:51 -0500
committerWilliam Langford <wlangfor@gmail.com>2020-03-02 10:55:51 -0500
commit8c61ebad0aaee3f5293c5e5077c0aeb0e8c232ec (patch)
treed62b837c206adb8f985e339173648ebd6491a2e8
parentd24c3d22638da7c2b166397a2765f5309c78d3de (diff)
Minor fixes to website generation
-rwxr-xr-xdocs/build_website.py10
-rw-r--r--docs/site.yml2
-rw-r--r--docs/templates/shared/_head.html.j22
-rw-r--r--docs/templates/shared/_navbar.html.j24
4 files changed, 13 insertions, 5 deletions
diff --git a/docs/build_website.py b/docs/build_website.py
index 2dd27036..7e04cc7b 100755
--- a/docs/build_website.py
+++ b/docs/build_website.py
@@ -35,13 +35,21 @@ env.globals['navigation'] = ['tutorial', 'download', 'manual']
def generate_file(env, fname='content/1.tutorial/default.yml'):
path, base = os.path.split(fname)
path = os.path.relpath(path, 'content')
+ if path == '.':
+ path = ''
+ slug = 'index'
+ permalink = ''
+ else:
+ slug = os.path.basename(path)
+ permalink = path + '/'
+
output_dir = os.path.join('output', path)
output_path = os.path.join(output_dir, 'index.html')
template_name = re.sub(r".yml$", '.html.j2', base)
ctx = load_yml_file(fname)
- ctx.update(unique_ctr=itertools.count(1), permalink=path)
+ ctx.update(unique_ctr=itertools.count(1), permalink=permalink, slug=slug, navitem=path)
os.makedirs(output_dir, exist_ok=True)
env.get_template(template_name).stream(ctx).dump(output_path, encoding='utf-8')
diff --git a/docs/site.yml b/docs/site.yml
index cc050794..69a7c397 100644
--- a/docs/site.yml
+++ b/docs/site.yml
@@ -1,6 +1,6 @@
# The key value pairs found below are available within the templates.
-:url: https://stedolan.github.io/jq
+url: https://stedolan.github.io/jq
# This line is modified by the Makefile. To change the version number,
# edit the Autoconf version number at the top of configure.ac
diff --git a/docs/templates/shared/_head.html.j2 b/docs/templates/shared/_head.html.j2
index b6fafd35..f7242627 100644
--- a/docs/templates/shared/_head.html.j2
+++ b/docs/templates/shared/_head.html.j2
@@ -7,7 +7,7 @@
<title>{{headline}}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
- <link rel="canonical" href="{{ url }}{{ permalink | replace('/index','') }}" />
+ <link rel="canonical" href="{{ url }}/{{ permalink }}" />
<link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.5/spacelab/bootstrap.min.css" rel="stylesheet" integrity="sha256-j7Dtnd7ZjexEiPNbscbopFn9+Cs0b3TLipKsWAPHZIM= sha512-RFhfi6P8zWMAJrEGU+CPjuxPh3r/UUBGqQ+/o6WKPIVZmQqeOipGotH2ihRULuQ8wsMBoK15TSZqc/7VYWyuIw==" crossorigin="anonymous">
<link rel="stylesheet" href="{{ root }}/css/base.css" type="text/css">
<!--[if lt IE 9]>
diff --git a/docs/templates/shared/_navbar.html.j2 b/docs/templates/shared/_navbar.html.j2
index 3fa5f14c..be1eb377 100644
--- a/docs/templates/shared/_navbar.html.j2
+++ b/docs/templates/shared/_navbar.html.j2
@@ -13,8 +13,8 @@
<div class="navbar-collapse collapse" id="nav-collapse">
<ul class="nav navbar-nav">
{% for item in navigation %}
- <li {% if item == permalink %} class="active" {% endif %}>
- <a href="{{root}}/{{item}}">{{item | capitalize}}</a>
+ <li {% if item == navitem %} class="active" {% endif %}>
+ <a href="{{root}}/{{item}}/">{{item | capitalize}}</a>
</li>
{% endfor %}
<li><a href="https://github.com/stedolan/jq/issues">Issues</a></li>