Add support for ugly urls to allow for offline sites with no webserver

This commit is contained in:
Che 2022-07-23 04:13:15 -04:00
parent d9d1698c5d
commit c50ccf9fb1
4 changed files with 41 additions and 12 deletions

View file

@ -11,4 +11,11 @@ highlight_theme = "base16-ocean-light"
logo = "https://easydocs.codeandmedia.com/logo.svg"
release = "https://api.github.com/repos/getzola/zola/releases/latest"
favicon = "https://www.getzola.org/favicon.ico"
easydocs_logo_always_clickable = false
easydocs_logo_always_clickable = false
# For use with offline sites. If set to true template links are generated with the full path indcluding index.html
# Insired by Abridge theme https://www.getzola.org/themes/abridge/
# Notes:
# - Also requries the base URL to be set to the local folder where the site is stored eg. base_url = /home/user/mysite/public/
# - This is not portable and only works with a specific local folder
easydocs_uglyurls = false

View file

@ -29,9 +29,13 @@
</script>
{% endif -%}
<main>
{% if not config.extra.easydocs_uglyurls -%}
{% set _ugly_url = "" -%}
{% else %}
{% set _ugly_url = "index.html" -%}
{% endif -%}
{% block nav -%}
{%- block nav -%}
<nav>
{% if config.extra.logo -%}
{% set _logo = config.extra.logo -%}
@ -41,13 +45,13 @@
{% if current_path == "/" and not config.extra.easydocs_logo_always_clickable -%}
<img src="{{ _logo | safe }}" alt="logo"/>
{% else -%}
<a href="{{ config.base_url }}">
<a href="{{ config.base_url }}{{ _ugly_url }}">
<img src="{{ _logo | safe }}" alt="logo"/>
</a>
{% endif -%}
{% else -%}
<h1><a href="{{ config.base_url }}">{{ config.title }}</a></h1>
<h1><a href="{{ config.base_url }}{{ _ugly_url }}">{{ config.title }}</a></h1>
{% endif -%}
{% if config.extra.release -%}
@ -69,7 +73,7 @@
<ul class="subtree">
{% for page in subsection.pages -%}
<li {% if current_path == page.path %}class="active"{% endif %}>
<a href="{{ page.permalink | safe }}">{{ page.title }}</a>
<a href="{{ page.permalink | safe }}{{ _ugly_url }}">{{ page.title }}</a>
</li>
{% if page.toc -%}
@ -90,12 +94,19 @@
{% if header_count > 4 -%}
<ul id="toc">
{% for h2 in page.toc -%}
<li><a href="{{ h2.permalink | safe }}">{{ h2.title }}</a>
<li><a href="
{{ h2.permalink | safe }}{{ _ugly_url }}">{{ h2.title }}</a>
{% if h2.children -%}
<ul>
{% for h3 in h2.children -%}
<li>
<a href="{{ h3.permalink | safe }}">{{ h3.title }}</a>
<a href="
{{ h3.permalink | safe }}{{ _ugly_url }}">{{ h3.title }}</a>
</li>
{% endfor -%}
</ul>

View file

@ -1,14 +1,19 @@
<h2>Table of Contents</h2>
{% if not config.extra.easydocs_uglyurls -%}
{% set _ugly_url = "" -%}
{% else %}
{% set _ugly_url = "index.html" -%}
{% endif -%}
{% if section.subsections -%}
<ul>
{% for subsec in section.subsections -%}
{% set sec_ = get_section(path=subsec) -%}
<li>
<a href="{{ sec_.permalink | safe }}">{{ sec_.title }}</a>
<a href="{{ sec_.permalink | safe }}{{ _ugly_url }}">{{ sec_.title }}</a>
{% if sec_.pages -%}
<ul>
{% for page_ in sec_.pages -%}
<li><a href="{{ page_.permalink | safe }}">{{ page_.title }}</a></li>
<li><a href="{{ page_.permalink | safe }}{{ _ugly_url }}">{{ page_.title }}</a></li>
{% endfor %}
</ul>
{% endif -%}

View file

@ -3,6 +3,12 @@
{% block title %} {{ config.title }} | {{ section.title }} {% endblock title %}
{% block content %}
{% if not config.extra.easydocs_uglyurls -%}
{% set _ugly_url = "" -%}
{% else %}
{% set _ugly_url = "index.html" -%}
{% endif -%}
{% if section.word_count > 0 -%}
{{ section.content | safe }}
{% else -%}
@ -13,7 +19,7 @@
<ul>
{% for subsec in section.subsections -%}
{% set sec_ = get_section(path=subsec) -%}
<li><a href="{{ sec_.permalink | safe }}">{{ sec_.title }}</a></li>
<li><a href="{{ sec_.permalink | safe }}{{ _ugly_url }}">{{ sec_.title }}</a></li>
{% endfor %}
</ul>
{% endif -%}
@ -22,7 +28,7 @@
<ul>
{% if section.pages -%}
{% for page in section.pages -%}
<li><a href="{{ page.permalink | safe }}">{{ page.title }}</a></li>
<li><a href="{{ page.permalink | safe }}{{ _ugly_url }}">{{ page.title }}</a></li>
{% endfor -%}
{% else -%}
<li>No pages</li>