Merge pull request #12 from LASSAT-YU/master

Add offline site support
This commit is contained in:
Roman 2022-07-30 16:19:26 +02:00 committed by GitHub
commit 6aab3eef30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 14 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,14 @@
</script>
{% endif -%}
<main>
{# Create variable to allow appending index.html at end of links if set in config #}
{% 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 -%}
@ -39,15 +44,15 @@
{% set _logo = get_url(path=config.extra.logo) -%}
{% endif -%}
{% if current_path == "/" and not config.extra.easydocs_logo_always_clickable -%}
<img src="{{ _logo | safe }}" alt=""/>
<img src="{{ _logo | safe }}" alt="logo"/>
{% else -%}
<a href="{{ config.base_url }}">
<img src="{{ _logo | safe }}" alt=""/>
<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 +74,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 +95,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

@ -4,11 +4,11 @@
{% 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

@ -13,7 +13,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 +22,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>