From 8c61ebad0aaee3f5293c5e5077c0aeb0e8c232ec Mon Sep 17 00:00:00 2001 From: William Langford Date: Mon, 2 Mar 2020 10:55:51 -0500 Subject: Minor fixes to website generation --- docs/build_website.py | 10 +++++++++- docs/site.yml | 2 +- docs/templates/shared/_head.html.j2 | 2 +- docs/templates/shared/_navbar.html.j2 | 4 ++-- 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 @@ {{headline}} - +