diff options
| author | Jieiku | 2023-08-17 12:16:18 -0700 |
|---|---|---|
| committer | Jieiku | 2023-08-17 12:16:18 -0700 |
| commit | 3e5d8a96e9eae21a799f327cd8a52adb891ebe66 (patch) | |
| tree | 6a1377b5207e4e3555f65ca162014468c64d6985 /templates | |
| parent | 1d9be812c25508a5dc36afb9e80669b668a47190 (diff) | |
| parent | 0983915e23793c28dd0bee149fd2ec05a7e96a94 (diff) | |
| download | abridge-3e5d8a96e9eae21a799f327cd8a52adb891ebe66.tar.gz abridge-3e5d8a96e9eae21a799f327cd8a52adb891ebe66.tar.bz2 abridge-3e5d8a96e9eae21a799f327cd8a52adb891ebe66.zip | |
resolve merge conflicts
Diffstat (limited to 'templates')
26 files changed, 554 insertions, 332 deletions
diff --git a/templates/404.html b/templates/404.html index 02c7688..f3fbfe9 100644 --- a/templates/404.html +++ b/templates/404.html @@ -17,8 +17,15 @@ {%- block content %} <div> - <h1>Page not found :(</h1> - <p>The page you are looking for doesn't exist or has been moved.</p> - <p>Try using the search, or <a href="{{ config.base_url | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">go home</a>.</p> + <h1>404 :(</h1> + {#- Default English message #} + <p>Page not found, maybe moved{% if config.languages | length > 0 %} or not in this language{% endif %}. {% if config.build_search_index %}Try searching or{% endif %} <a href="{{ config.base_url | safe }}/{%- if config.extra.uglyurls %}index.html{%- endif %}">go to homepage</a>.</p> + + {# Iterate through each language and display the localised 404 message #} + {%- for lcode, language in config.languages -%} + {%- if lcode != config.default_language -%} + <p>{{ trans(key="404_not_found", lang=lcode) }}. {% if config.build_search_index %}{{ trans(key="404_try_search", lang=lcode) }}{% endif %} <a href="{{ config.base_url }}/{{ lcode }}/{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ trans(key="404_go_home", lang=lcode) }}</a>.</p> + {%- endif -%} + {%- endfor -%} </div> {%- endblock content %} diff --git a/templates/archive.html b/templates/archive.html new file mode 100644 index 0000000..eff70a9 --- /dev/null +++ b/templates/archive.html @@ -0,0 +1,83 @@ +{# +This Page Shows the Posts Grouped by Year: example.com/archive/ +This Template can also be used as the rendering template for Sections, eg: example.com/blog/ example.com/software/ +#} + +{% extends "base.html" %} + +{%- block seo %} + {{- super() }} + {%- set title = "Archive" %} + + {%- if config.title %} + {%- set title_addition = title_separator ~ config.title %} + {%- else %} + {%- set title_addition = "" %} + {%- endif %} + + {%- set description = config.description %} + + {{- macros_head::seo(config=config, title=title, title_addition=title_addition, description=description, is_home=true) }} +{%- endblock seo %} + +{%- block content %} + {#- The following line is checking if the template is being used for the archive page or a section #} + {%- if current_path is matching("^(/[[:alpha:]][[:alpha:]])?/archive/$") %} + {%- set sec = "" %} + {%- else %} + {%- set langpath = "/" %} + {%- if lang != config.default_language %} + {%- set langpath = "/" ~ lang ~ "/" %} + {%- endif %} + + {%- set sec = current_path | trim_start_matches(pat=langpath) | split(pat="/page/") | slice(end=1) | join(sep="") | trim_end_matches(pat="/") %} + {%- set sec = sec ~ "/" %} + {%- endif %} + + {%- if lang == config.default_language %} + {%- set section_item = get_section(path=sec ~ "_index.md") %} + {%- else %} + {%- set section_item = get_section(path=sec ~ "_index." ~ lang ~ ".md") %} + {%- endif %} + {%- if sec != "" %} + {#- the section always overrides the config -#} + {%- if section_item.extra and 'hide_section_dates' in section_item.extra -%} + {%- set hide_section_dates = section_item.extra.hide_section_dates -%} + {%- elif config.extra.hide_section_dates -%} + {%- set hide_section_dates = true -%} + {%- endif -%} + {%- endif %} + <div> + {%- if section_item.title %} + <h2>{{ section_item.title }}</h2> + {%- endif %} + {{- section_item.content | safe }} + {%- if config.extra.archive_reverse %} + {%- for year, posts in section_item.pages | sort(attribute="year") | reverse | group_by(attribute="year") %} + {%- if not hide_section_dates %} + {%- if section_item.title %} + <h3>{{ year }}</h3> + {%- else %} + <h2>{{ year }}</h2> + {%- endif %} + {%- endif %} + {%- for post in posts %} + <p><a href="{{ post.permalink | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ post.title }}</a>{%- if not hide_section_dates %} - <time datetime="{{ post.date }}">{{ post.date | date(format="%F") }}</time>{%- endif %}</p> + {%- endfor %} + {%- endfor %} + {%- else %} + {%- for year, posts in section_item.pages | group_by(attribute="year") %} + {%- if not hide_section_dates %} + {%- if section_item.title %} + <h3>{{ year }}</h3> + {%- else %} + <h2>{{ year }}</h2> + {%- endif %} + {%- endif %} + {%- for post in posts %} + <p><a href="{{ post.permalink | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ post.title }}</a>{%- if not hide_section_dates %} - <time datetime="{{ post.date }}">{{ post.date | date(format="%F") }}</time>{%- endif %}</p> + {%- endfor %} + {%- endfor %} + {%- endif %} + </div> +{%- endblock content %} diff --git a/templates/base.html b/templates/base.html index 736912f..228b396 100644 --- a/templates/base.html +++ b/templates/base.html @@ -3,13 +3,13 @@ {%- import "macros/page.html" as page_macros %} {%- import "macros/macros.html" as macros %} <!DOCTYPE html> -<html lang="{{ config.extra.language_code | default(value='en-US') }}"> +<html lang="{%- if lang != config.default_language %}{{ lang }}{% else %}{{ config.extra.language_code | default(value=lang) }}{% endif %}"> <head> {{- macros_head::theme(config=config) }} {{- macros_head::stylesheets(config=config) }} <meta charset="utf-8" /> <meta http-equiv="x-ua-compatible" content="ie=edge" /> - <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> {{- macros_head::stylesheets_preload(config=config) }} {{- macros_head::js(config=config) }} <meta name="base" content="{{ config.base_url | safe }}" /> @@ -28,11 +28,7 @@ {{- macros_head::security(config=config) }} {{- macros_head::favicons(config=config) }} <noscript><link rel="stylesheet" href="{{ get_url(path='nojs.css', trailing_slash=false) | safe }}" /></noscript> - {%- block comments_init %} - {%- if config.extra.comments.hyvor %} - <script async src="https://talk.hyvor.com/embed/embed.js" type="module"></script> - {%- endif %} {%- endblock comments_init %} </head> <body> @@ -41,36 +37,62 @@ <nav> <div> {%- if config.extra.logo -%} - <h1><a href="{{ config.base_url | safe }}/{%- if config.extra.uglyurls %}index.html{%- endif %}"> + <h1><a href="{{ get_url(path="/", lang=lang) }}{%- if config.extra.uglyurls %}/index.html{%- endif %}"> {%- if config.extra.logo.file -%} <img src="{{ config.base_url | safe }}/{{ config.extra.logo.file | safe }}"{%- if config.extra.logo.alt %} alt="{{ config.extra.logo.alt | safe }}"{%- endif %}{%- if config.extra.logo.width %} width="{{ config.extra.logo.width | safe }}"{%- endif %}{%- if config.extra.logo.height %} height="{{ config.extra.logo.height | safe }}"{%- endif %} /> {%- endif -%} {%- if config.extra.logo.text -%}{{ config.extra.logo.text | safe }}{%- endif -%} </a></h1> {%- elif config.extra.textlogo -%} - <h1><a href="{{ config.base_url | safe }}/{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ config.extra.textlogo | safe }}</a></h1> + <h1><a href="{{ get_url(path="/", lang=lang) }}{%- if config.extra.uglyurls -%} + {%- if lang == config.default_language -%}/{%- endif -%} + index.html{%- endif -%}">{{ config.extra.textlogo | safe }}</a></h1> {%- elif config.title -%} - <h1><a href="{{ config.base_url | safe }}/{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ config.title | safe }}</a></h1> + <h1><a href="{{ get_url(path="/", lang=lang) }}{%- if config.extra.uglyurls %}/index.html{%- endif %}">{{ config.title | safe }}</a></h1> {%- endif -%} </div> <div> - <ul> - {%- for i in config.extra.menu -%} - <li> <h2><a href="{{ get_url(path=i.url, trailing_slash=i.slash) }}{%- if i.slash and config.extra.uglyurls %}index.html{%- endif %}"{% if i.blank %} target="_blank"{% endif %}>{{ i.name | safe }}</a></h2> </li> - {%- endfor -%} - {%- if config.extra.js_theme -%} - <li class="js">{%- if config.extra.icon_adjust -%}<i type="reset" id="mode" class="{{ config.extra.icon_adjust }}"></i>{%- else -%}<i type="reset" id="mode" class="mode">☀</i>{%- endif -%}</li> + {% set js_switcher=config.extra.js_switcher | default(value=true) %} + {%- if config.extra.menu or js_switcher %} + {%- if config.extra.menu %} + {%- for i in config.extra.menu -%} + <a href="{{ get_url(path=i.url, lang=lang, trailing_slash=i.slash) }}{%- if i.slash and config.extra.uglyurls %}index.html{%- endif %}"{% if i.blank %} target="_blank"{% endif %}> + {%- if lang != config.default_language %} {{ trans(key=i.name | safe, lang=lang) }} {% else %} {{ i.name | safe }} {% endif -%} + </a> + {%- endfor -%} + {%- endif -%} + {%- if js_switcher -%} + {%- set icon_adjust=config.extra.icon_adjust | default(value="svgs adjust") -%} + {%- if icon_adjust -%}<i type="reset" id="mode" class="js {{ icon_adjust }}"></i>{%- else -%}<i type="reset" id="mode" class="js mode">☀</i>{%- endif -%} + {%- endif -%} + {%- endif -%} + {%- if config.languages | length > 0 %} + <div class="dropdown" type="Button"> {%- if lang != config.default_language %}{{ trans(key="flag" | safe, lang=lang) }}{% else %}{{ config.extra.flag.en }}{% endif %} + {%- if current_url %} + <div class="dropdown-content"> + {%- for lcode,flag in config.extra.flag -%} + {%- if lang != lcode -%} + {%- if lcode == config.default_language -%} + <a type="Button" href="{{ current_url | replace(from=current_path | truncate(length=4, end=""), to="/") | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ flag }}</a><br /> + {%- else -%} + <a type="Button" href="{{ current_url | replace(from=config.base_url, to=config.base_url ~ "/" ~ lcode) | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ flag }}</a><br /> {%- endif -%} - </ul> + {%- endif -%} + {%- endfor -%} + </div> + {%- endif %} + </div> + {%- endif %} </div> {%- if config.build_search_index %} + {%- set icon_search=config.extra.icon_search | default(value="svgs search") %} <div> <form autocomplete=off class="js" name="goSearch" id="searchbox"> <div class="searchd"> - <input id="searchinput" type="text" placeholder="Search" title="Search"{% if config.extra.search_library %}{% if config.extra.search_library == "stork" %} data-stork="stork" {% endif %}{% endif %} /> - <button type="submit" title="Search">{%- if config.extra.icon_search -%}<i class="{{ config.extra.icon_search }}"></i>{%- else -%}<span class="si">⌕</span>{%- endif -%}</button> + <input id="searchinput" type="text" placeholder="{%- if lang != config.default_language %}{{ trans(key="Search" | safe, lang=lang) }}{% else %}Search{% endif %}" title="Search"{% if config.extra.search_library %}{% if config.extra.search_library == "stork" %} data-stork="stork" {% endif %}{% endif %} /> + <button type="submit" title="Search" class="{%- if icon_search -%}{{ icon_search }}{%- else -%}si{%- endif -%}">{%- if not icon_search -%}⌕{%- endif -%}</button> </div> - <div><div id="suggestions"{% if config.extra.search_library %}{% if config.extra.search_library == "stork" %} data-stork="stork-output" {% endif %}{% endif %}></div></div> + <div class="results"><div id="suggestions"{% if config.extra.search_library %}{% if config.extra.search_library == "stork" %} data-stork="stork-output" {% endif %}{% endif %}></div></div> </form> </div> {%- endif %} @@ -95,26 +117,36 @@ <hr /> {%- endif %} <div class="c"> - {{- social_macros::social_links(social_config=config.extra.social, config=config) }} + {{- social_macros::social_links(config=config) }} {#- Copyright START #} + {%- set copyright_start_string=config.extra.copyright_start_string | default(value="©") %} + {%- if copyright_start_string %}{%- set copyright_start_string=copyright_start_string ~ " " %}{%- endif %} {%- set copyright_start_year=config.extra.copyright_start_year | default(value="") %} {%- if copyright_start_year %}{%- set copyright_start_year=copyright_start_year ~ "-" %}{%- endif %} {%- set copyright_end_year=config.extra.copyright_end_year | default(value=now() | date(format="%Y")) %} - <p{%- if config.extra.footer_size %} class="{{ config.extra.footer_size }}"{% endif %}>Copyright © {{ copyright_start_year ~ copyright_end_year }} {{ config.title }}</p> + {%- if config.extra.copyright_entity %}{%- set copyright_entity= " " ~ config.extra.copyright_entity %}{%- else %}{%- set copyright_entity= " " ~ config.title %}{%- endif %} + {%- set copyright_end_string=config.extra.copyright_end_string | default(value="") %} + {%- if copyright_end_string %}{%- set copyright_end_string= " " ~ copyright_end_string %}{%- endif %} + <p{%- if config.extra.footer_size %} class="{{ config.extra.footer_size }}"{% endif %}> {{ copyright_start_string ~ copyright_start_year ~ copyright_end_year ~ copyright_entity ~ copyright_end_string }}</p> {#- Copyright END #} + {%- if config.extra.menu_footer %} <nav> - <ul> - {%- for i in config.extra.menu_footer -%} - <li{%- if config.extra.footer_size %} class="{{ config.extra.footer_size }}"{% endif %}> <a href="{{ get_url(path=i.url, trailing_slash=i.slash) }}{%- if i.slash and config.extra.uglyurls %}index.html{%- endif %}"{% if i.blank %} target="_blank"{% endif %}> {{ i.name | safe }} </a> </li> - {%- endfor -%} - </ul> + {%- for i in config.extra.menu_footer -%} + {%- if i.url != "sitemap.xml" %} + {%- set furl=get_url(path=i.url, lang=lang, trailing_slash=i.slash) %} + {%- else %} + {%- set furl=get_url(path=i.url, trailing_slash=i.slash) %} + {%- endif %} + <a{%- if config.extra.footer_size %} class="{{ config.extra.footer_size }}"{% endif %} href="{{ furl | safe }}{%- if i.slash and config.extra.uglyurls %}index.html{%- endif %}"{% if i.blank %} target="_blank"{% endif %}>{% if lang != config.default_language %} {{ trans(key=i.name | safe, lang=lang) }} {% else %} {{ i.name | safe }} {% endif %}</a> + {%- endfor %} </nav> + {%- endif %} {%- if config.extra.footer_credit | default(value=true) %} {%- if config.extra.footer_credit_override %} {{ config.extra.footer_credit_override | safe }} {%- else %} - <p{%- if config.extra.footer_size %} class="{{ config.extra.footer_size }}"{% endif %}>Powered by <a href="https://www.getzola.org/" target="_blank">Zola</a> and <a href="https://github.com/jieiku/abridge/" target="_blank">Abridge</a></p> + <p{%- if config.extra.footer_size %} class="{{ config.extra.footer_size }}"{% endif %}>{% if lang != config.default_language -%} {{ trans(key="Powered_by" | safe, lang=lang) }} {% else -%} Powered by {% endif %}<a href="https://www.getzola.org/" target="_blank">Zola</a> {%- if lang != config.default_language %} {{ trans(key="and" | safe, lang=lang) }} {% else %} and {% endif -%} <a href="https://github.com/jieiku/abridge/" target="_blank">Abridge</a></p> {%- endif %} {%- endif %} </div> diff --git a/templates/categories/list.html b/templates/categories/list.html index 1ded228..2e325c9 100644 --- a/templates/categories/list.html +++ b/templates/categories/list.html @@ -18,13 +18,13 @@ {%- block content %} <div> <div class="c"> - <h1>{{ terms | length }} Categories</h1> - <p>{% for term in terms %} [<a href="#{{ term.name }}">{{ term.name }}</a>] {% endfor %}</p> + <h1>{{ terms | length }} {%- if lang != config.default_language %} {{ trans(key="Categories" | safe, lang=lang) }} {% else %} Categories {% endif %}</h1> + <p>{% for term in terms %} [<a href="#{{ term.name }}">{{ term.name }}</a>]<sup>{{ term.pages | length }}</sup> {% endfor %}</p> </div> {%- for term in terms %} - <h2 id="{{ term.name }}"><a href="{{ term.permalink | safe }}">{{ term.name }}</a></h2> + <h2 id="{{ term.name }}"><a href="{{ term.permalink | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ term.name }}</a></h2> {%- for page in term.pages %} - <p><a href="{{ page.permalink | safe }}">{{ page.title }}</a> - <time datetime="{{ page.date }}">{{ page.date | date(format="%F") }}</time></p> + <p><a href="{{ page.permalink | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ page.title }}</a> - <time datetime="{{ page.date }}">{{ page.date | date(format="%F") }}</time></p> {%- endfor %} {%- endfor %} </div> diff --git a/templates/categories/single.html b/templates/categories/single.html index 1f5e48c..9e667b4 100644 --- a/templates/categories/single.html +++ b/templates/categories/single.html @@ -21,7 +21,7 @@ {%- for year, posts in term.pages | group_by(attribute="year") %} <h3>{{ year }}</h3> {%- for page in posts %} - <p><a href="{{ page.permalink | safe }}">{{ page.title }}</a> - <time datetime="{{ page.date }}">{{ page.date | date(format="%F") }}</time></p> + <p><a href="{{ page.permalink | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ page.title }}</a> - <time datetime="{{ page.date }}">{{ page.date | date(format="%F") }}</time></p> {%- endfor %} {%- endfor %} </div> diff --git a/templates/contact.fr.html b/templates/contact.fr.html new file mode 100644 index 0000000..d23569d --- /dev/null +++ b/templates/contact.fr.html @@ -0,0 +1,49 @@ +{# Cette page affiche la page de contact, par exemple: example.com/contact/ #} + +{% extends "base.html" %} + +{%- block seo %} + {{- super() }} + {%- set title_addition = "" %} + + {%- if page.title and config.title %} + {%- set title = page.title %} + {%- set title_addition = title_separator ~ config.title %} + {%- elif page.title %} + {%- set title = page.title %} + {%- else %} + {%- set title = config.title %} + {%- endif %} + + {%- if page.description %} + {%- set description = page.description %} + {%- else %} + {%- set description = config.description %} + {%- endif %} + + {{- macros_head::seo(config=config, title=title, title_addition=title_addition, description=description) }} +{%- endblock seo %} + +{%- block content %} + <div> + <p>Vous voulez entrer en contact ? Remplissez le formulaire ci-dessous pour m'envoyer un message et je vous répondrai dans les plus brefs délais !</p> + <form name="contact" method="POST"> + <p> + <label for="name">Nom</label> + <input type="text" placeholder="Nom" id="name" required data-validation-required-message="S'il vous plaît entrez votre nom." /> + </p> + <p> + <label for="email">Adresse e-mail</label> + <input type="email" placeholder="nom@example.com" id="email" required data-validation-required-message="Veuillez saisir votre adresse e-mail." /> + </p> + <p> + <label for="message">Message</label> + <textarea rows="5" placeholder="Message" id="message" required data-validation-required-message="Veuillez entrer un message."></textarea> + </p> + <div id="success"></div> + <p> + <button type="submit" id="sendMessageButton">Envoyer</button> + </p> + </form> + </div> +{%- endblock content %} diff --git a/templates/index.html b/templates/index.html index 7c8c45a..ce224c0 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,3 +1,8 @@ +{# +This Page Shows the Posts with a short summary on the index: example.com/ +This Template can also be used as the rendering template for Sections, eg: example.com/blog/ example.com/software/ +#} + {%- extends "base.html" %} {%- block seo %} @@ -54,12 +59,30 @@ {%- endfor %} {{- macros::pagination(paginator=paginator, config=config) }} </div> - {%- set section_item = get_section(path="_index.md") %} {%- if config.extra.recent | default(value=true) %} + {#- The following line is checking if the template is being used for the root or a section #} + {%- if current_path is matching("^(/[[:alpha:]][[:alpha:]])?(/page/[[:digit:]]+)?/$") %} + {%- set sec = "" %} + {%- else %} + {%- if lang == config.default_language %} + {%- set sec = current_path | trim_start_matches(pat="/") | split(pat="/page/") | slice(end=1) | join(sep="") | trim_end_matches(pat="/") %} + {%- set sec = sec ~ "/" %} + {%- else %} + {%- set sec = current_path | trim_start_matches(pat="/" ~ lang ~ "/") | split(pat="/page/") | slice(end=1) | join(sep="") | trim_end_matches(pat="/") %} + {%- set sec = sec ~ "/" %} + {%- endif %} + {%- endif %} + + {%- if lang == config.default_language %} + {%- set section_item = get_section(path=sec ~ "_index.md") %} + {%- else %} + {%- set section_item = get_section(path=sec ~ "_index." ~ lang ~ ".md") %} + {%- endif %} <div class="toc"> <div class="toc-sticky"> - <h1><span class="s75">Recent Posts</span></h1> - {%- for page in section_item.pages | slice(end=config.extra.recent_items) %} + <h1><span class="s70">{%- if lang != config.default_language %}{{ trans(key="Recent_Posts" | safe, lang=lang) }}{% else %}Recent Posts{% endif %}</span></h1> + {%- set recent_items=config.extra.recent_items | default(value=9) -%} + {%- for page in section_item.pages | slice(end=recent_items) %} {{- page_macros::page_listing(page=page, config=config) }} {%- endfor %} </div> diff --git a/templates/macros/create_stork_toml.html b/templates/macros/create_stork_toml.html index f754e2e..ee1d765 100644 --- a/templates/macros/create_stork_toml.html +++ b/templates/macros/create_stork_toml.html @@ -7,9 +7,9 @@ {% endif -%} {%- endif -%} {%- endfor -%} -{%- if found -%}{%- if section.subsections -%}, +{%- if found and section.subsections -%}, {% for subsection in section.subsections -%} {{ self::from_section(section=subsection) }} {%- endfor -%} -{%- endif -%}{%- endif -%} -{%- endmacro from_section -%}
\ No newline at end of file +{%- endif -%} +{%- endmacro from_section -%} diff --git a/templates/macros/create_tinysearch_json.html b/templates/macros/create_tinysearch_json.html index a28d9dc..fcc1f5a 100644 --- a/templates/macros/create_tinysearch_json.html +++ b/templates/macros/create_tinysearch_json.html @@ -18,10 +18,10 @@ {%- if not loop.last -%},{%- endif %} {%- endif -%} {%- endfor -%} -{%- if found -%}{%- if section.subsections -%} +{%- if found and section.subsections -%} , {%- for subsection in section.subsections -%} {{ self::from_section(section=subsection) }} {%- endfor -%} -{%- endif -%}{%- endif -%} -{%- endmacro from_section -%}
\ No newline at end of file +{%- endif -%} +{%- endmacro from_section -%} diff --git a/templates/macros/head.html b/templates/macros/head.html index 528577a..35afa5b 100644 --- a/templates/macros/head.html +++ b/templates/macros/head.html @@ -1,20 +1,28 @@ {#- Theme Switcher Button to toggle between dark/light #} {%- macro theme(config) %} - {%- if config.extra.js_theme %} - {%- if config.extra.js_themeButton or config.extra.js_bundle %} - <script src="{{ get_url(path=config.extra.js_theme, trailing_slash=false) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path=config.extra.js_theme, sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- if config.extra.js_switcher | default(value=true) %} + {%- set js_theme=config.extra.js_theme | default(value="") -%} + {%- if not js_theme %} + {%- set js_theme="js/theme.min.js" -%} + {%- if config.extra.js_switcher_default %}{%- if config.extra.js_switcher_default == "light" %} + {%- set js_theme="js/theme_light.min.js" -%} + {%- endif %}{%- endif %} + <script src="{{ get_url(path=js_theme, trailing_slash=false) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=js_theme, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} {%- endif %} {%- endmacro %} -{%- macro stylesheets(config) %} - {%- if config.extra.stylesheets %}{%- for i in config.extra.stylesheets %} + +{%- macro stylesheets(config) %} + {%- set stylesheets=config.extra.stylesheets | default(value=[ "abridge.css" ]) -%} + {%- if stylesheets %}{%- for i in stylesheets %} <link rel="stylesheet" href="{{ get_url(path=i, trailing_slash=false, cachebust=true) | safe }}" /> {%- endfor %}{%- endif %} - {%- endmacro %} + + {%- macro stylesheets_preload(config) %} {%- if config.extra.fonts %}{%- for i in config.extra.fonts %} @@ -31,10 +39,11 @@ {%- if config.extra.math or page.extra.math %} - {%- if config.extra.katex_css %}{%- if config.extra.katex_css is matching("^http[s]?://") %} - <link rel="preload" as="style" class="preStyle" href="{{ config.extra.katex_css | safe }}"{%- if config.extra.integrity %} integrity="sha384-ZPe7yZ91iWxYumsBEOn7ieg8q/o+qh/hQpSaPow8T6BwALcXSCS6C6fSRPIAnTQs"{%- endif %} crossorigin="anonymous" /> + {%- set katex_css=config.extra.katex_css | default(value="katex.min.css") -%} + {%- if katex_css %}{%- if katex_css is matching("^http[s]?://") %} + <link rel="preload" as="style" class="preStyle" href="{{ katex_css | safe }}"{%- if config.extra.integrity | default(value=true) and config.extra.katex_css_integrity %} integrity="{{ config.extra.katex_css_integrity | safe }}"{%- endif %} crossorigin="anonymous" /> {%- else %} - <link rel="preload" as="style" class="preStyle" href="{{ get_url(path=config.extra.katex_css, trailing_slash=false) }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path=config.extra.katex_css, sha_type=384, base64=true) | safe }}"{%- endif %} /> + <link rel="preload" as="style" class="preStyle" href="{{ get_url(path=katex_css, trailing_slash=false) }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=katex_css, sha_type=384, base64=true) | safe }}"{%- endif %} /> {%- endif %}{%- endif %} {%- endif %} @@ -45,13 +54,14 @@ {%- macro feed(config) %} {%- if config.generate_feed %} - <link rel="alternate" type="{% if config.feed_filename is containing('atom') %}application/atom+xml{% else %}application/rss+xml{% endif %}" title="Atom/RSS Feed" href="{{ get_url(path=config.feed_filename, trailing_slash=false) | safe }}" /> + <link rel="alternate" type="{% if config.feed_filename is containing('atom') %}application/atom+xml{% else %}application/rss+xml{% endif %}" title="Atom/RSS Feed" href="{{ get_url(path=config.feed_filename, trailing_slash=false, lang=lang) | safe }}" /> {%- endif %} {%- endmacro %} {%- macro js(config) %} + {%- set search_library=config.extra.search_library | default(value="elasticlunr") -%} {%- set preStyle = false %} @@ -66,140 +76,91 @@ {%- endif %} {%- if config.extra.math or page.extra.math %} - {%- if config.extra.katex_css %} + {%- set katex_css=config.extra.katex_css | default(value="katex.min.css") -%} + {%- if katex_css %} {%- set preStyle = true %} {%- endif %} {%- endif %} -{%- if config.extra.js_bundle and config.build_search_index or config.extra.js_bundle and config.extra.search_library %} - - {%- if config.extra.js_search_facade %} - {#- dont load the index #} - {%- elif config.extra.search_library == "tinysearch" or config.extra.search_library == "stork" %} - {#- dont load the index #} - {%- elif config.extra.js_search_index %} - <script defer src="{{ get_url(path=config.extra.js_search_index, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path=config.extra.js_search_index, sha_type=384, base64=true) | safe }}"{%- endif %}></script> - {%- endif %} - - {%- if not config.extra.js_search_facade %} +{%- if config.extra.js_bundle %} + <script defer src="{{ get_url(path='js/abridge.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/abridge.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> - {%- if config.extra.js_switcher %} - <script defer src="{{ get_url(path='abridge-bundle-nofacade.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path='abridge-bundle-nofacade.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> - {%- else %} - <script defer src="{{ get_url(path='abridge-bundle-noswitcher.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path='abridge-bundle-nofacade.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- if config.build_search_index %} + {%- if search_library == "elasticlunr" %} + {%- if lang != "en" %} + <script defer src="{{get_url(path='js/lunr.stemmer.support.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/lunr.stemmer.support.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> + <script defer src="{{get_url(path='js/lunr.' ~ lang ~ '.min.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/lunr.' ~ lang ~ '.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} - - {%- elif config.extra.search_library == "tinysearch" %} - <script defer src="{{ get_url(path='abridge-bundle-tinysearch.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path='abridge-bundle-tinysearch.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> - {%- elif config.extra.search_library == "stork" %} - <script defer src="{{ get_url(path='abridge-bundle-stork.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path='abridge-bundle-stork.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> - {%- else %} - - {%- if config.extra.js_switcher %} - <script defer src="{{ get_url(path='abridge-bundle.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path='abridge-bundle.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> - {%- else %} - <script defer src="{{ get_url(path='abridge.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path='abridge.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} - {%- endif %} - -{%- elif config.build_search_index or config.extra.search_library %} - - {#- no bundle #} +{%- else %} {%- if preStyle == true %} - {%- if config.extra.js_prestyle %} - <script defer src="{{ get_url(path=config.extra.js_prestyle, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path=config.extra.js_prestyle, sha_type=384, base64=true) | safe }}"{%- endif %}></script> - {%- endif %} - {%- endif %} - - {%- if config.extra.js_theme %} - {%- if config.extra.js_themeButton %} - <script defer src="{{ get_url(path=config.extra.js_themeButton, trailing_slash=false) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path=config.extra.js_themeButton, sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- set js_prestyle=config.extra.js_prestyle | default(value="js/prestyle.js") -%} + {%- if js_prestyle %} + <script defer src="{{ get_url(path=js_prestyle, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=js_prestyle, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} {%- endif %} - {%- if config.extra.js_email %} - {%- if config.extra.social.mail_encode %} - <script defer src="{{ get_url(path=config.extra.js_email, trzailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path=config.extra.js_email, sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- if config.extra.js_switcher | default(value=true) %} + {%- set js_theme=config.extra.js_theme | default(value="js/theme.min.js") -%} + {%- if js_theme %} + {%- set js_themeButton=config.extra.js_themeButton | default(value="js/theme_button.js") -%} + {%- if js_themeButton %} + <script defer src="{{ get_url(path=js_themeButton, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=js_themeButton, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} {%- endif %} - - {%- if config.extra.js_codecopy %} - <script defer src="{{ get_url(path=config.extra.js_codecopy, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path=config.extra.js_codecopy, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} - {%- if config.extra.js_search_facade %} - {%- if config.extra.search_library %} - {%- if config.extra.search_library == "tinysearch" %} - <script defer src="{{ get_url(path='search_facade_tinysearch.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path='search_facade_tinysearch.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> - {%- elif config.extra.search_library == "stork" %} - <script defer src="{{ get_url(path='search_facade_stork.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path='search_facade_stork.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> - {%- endif %} + {%- set js_email=config.extra.js_email | default(value="js/email.js") -%} + {%- if js_email %} + {%- if config.extra.mail_encode | default(value=true) %} + <script defer src="{{ get_url(path=js_email, trzailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=js_email, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} - <script defer src="{{ get_url(path='search_facade.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path='search_facade.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} - {%- if config.extra.js_search_facade or config.extra.search_library %} - {#- dont load the index/search #} - {%- elif config.extra.js_search_index %} - <script defer src="{{ get_url(path=config.extra.js_search_index, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path=config.extra.js_search_index, sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- set js_codecopy=config.extra.js_codecopy | default(value="js/codecopy.js") -%} + {%- if js_codecopy %} + <script defer src="{{ get_url(path=js_codecopy, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=js_codecopy, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} - {%- if config.extra.js_search_facade %} - {#- dont load the index/search #} - {%- else %} - {%- if config.extra.search_library == "tinysearch" %} - <script defer type="module" src="{{ get_url(path='tinysearch.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path='tinysearch.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> - {%- elif config.extra.search_library == "stork" %} - <script defer type="module" src="{{ get_url(path='stork.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path='stork.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> - {%- else %} - <script defer src="{{ get_url(path='elasticlunr.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path='elasticlunr.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> - <script defer src="{{ get_url(path='search.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path='search.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> - {%- endif %} - {%- endif %} - -{%- elif config.extra.js_bundle %} - - {#- no search #} + {%- if search_library == "tinysearch" %} + <script defer type="module" src="{{ get_url(path='js/search_tinysearch.min.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/search_tinysearch.min.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- elif search_library == "stork" %} + <script defer type="module" src="{{ get_url(path='js/search_stork.min.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/search_stork.min.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- elif config.build_search_index %} - {%- if config.extra.js_switcher %} - - <script defer src="{{ get_url(path='abridge-bundle-nosearch.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path='abridge-bundle-nosearch.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> - {%- else %} - - <script defer src="{{ get_url(path='abridge-bundle-noswitchernosearch.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path='abridge-bundle-noswitchernosearch.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- set search_index_format="elasticlunr_json" -%} + {%- if config.search.index_format %} + {%- if config.search.index_format == "elasticlunr_javascript" %} + {%- set search_index_format="elasticlunr_javascript" -%} + {%- endif %} {%- endif %} -{%- else %} - - {#- no bundle or search #} + {%- set uglyurls=config.extra.uglyurls | default(value=false) -%} + {%- if search_index_format == "elasticlunr_javascript" %} + <script defer src="{{ get_url(path='js/elasticlunr.min.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/elasticlunr.min.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> + <script defer src="{{ get_url(path='search_index.' ~ lang ~ '.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='search_index.' ~ lang ~ '.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> - {%- if preStyle == true %} - {%- if config.extra.js_prestyle %} - <script defer src="{{ get_url(path=config.extra.js_prestyle, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path=config.extra.js_prestyle, sha_type=384, base64=true) | safe }}"{%- endif %}></script> - {%- endif %} + {%- if uglyurls %} + <script defer src="{{ get_url(path='js/searchjavaugly.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/searchjavaugly.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- else %} + <script defer src="{{ get_url(path='js/searchjava.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/searchjava.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} - {%- if config.extra.js_theme %} - {%- if config.extra.js_themeButton or config.extra.js_bundle %} - <script defer src="{{ get_url(path=config.extra.js_themeButton, trailing_slash=false) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path=config.extra.js_themeButton, sha_type=384, base64=true) | safe }}"{%- endif %}></script> - {%- endif %} + {%- else %} + <script defer src="{{ get_url(path='js/search_elasticlunr.min.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/search_elasticlunr.min.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} - {%- if config.extra.js_email %} - {%- if config.extra.social.mail_encode %} - <script defer src="{{ get_url(path=config.extra.js_email, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path=config.extra.js_email, sha_type=384, base64=true) | safe }}"{%- endif %}></script> - {%- endif %} + {%- if lang != "en" %} + <script defer src="{{ get_url(path='js/lunr.stemmer.support.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/lunr.stemmer.support.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> + <script defer src="{{ get_url(path='js/lunr.' ~ lang ~ '.min.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/lunr.' ~ lang ~ '.min.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} - {%- if config.extra.js_codecopy %} - <script defer src="{{ get_url(path=config.extra.js_codecopy, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path=config.extra.js_codecopy, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} - {%- endif %} @@ -208,31 +169,38 @@ {#- https://github.com/KaTeX/KaTeX/tree/main/contrib/mathtex-script-type/ #} {%- if config.extra.math or page.extra.math %} -{%- if config.extra.katex_bundle %} - <script defer src="{{ get_url(path=config.extra.katex_bundle, trailing_slash=false, cachebust=true) }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path=config.extra.katex_bundle, sha_type=384, base64=true) | safe }}"{%- endif %}></script> +{%- set katex_bundle=config.extra.katex_bundle | default(value="js/katexbundle.min.js") -%} +{%- if katex_bundle %} + <script defer src="{{ get_url(path=katex_bundle, trailing_slash=false, cachebust=true) }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=katex_bundle, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- else %} - {%- if config.extra.katex_js %}{%- if config.extra.katex_js is matching("^http[s]?://") %} - <script defer src="{{ config.extra.katex_js | safe }}"{%- if config.extra.integrity %} integrity="sha384-ljao5I1l+8KYFXG7LNEA7DyaFvuvSCmedUf6Y6JI7LJqiu8q5dEivP2nDdFH31V4"{%- endif %} crossorigin="anonymous"></script> + {%- set katex_js=config.extra.katex_js | default(value="js/katex.min.js") -%} + {%- if katex_js %}{%- if katex_js is matching("^http[s]?://") %} + <script defer src="{{ katex_js | safe }}"{%- if config.extra.integrity | default(value=true) and config.extra.katex_js_integrity %} integrity="{{ config.extra.katex_js_integrity | safe }}"{%- endif %} crossorigin="anonymous"></script> {%- else %} - <script defer src="{{ get_url(path=config.extra.katex_js, trailing_slash=false, cachebust=true) }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path=config.extra.katex_js, sha_type=384, base64=true) | safe }}"{%- endif %}></script> + <script defer src="{{ get_url(path=katex_js, trailing_slash=false, cachebust=true) }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=katex_js, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %}{%- endif %} - {%- if config.extra.mathtex_js %}{%- if config.extra.mathtex_js is matching("^http[s]?://") %} - <script defer src="{{ config.extra.mathtex_js | safe }}"{%- if config.extra.integrity %} integrity="sha384-jiBVvJ8NGGj5n7kJaiWwWp9AjC+Yh8rhZY3GtAX8yU28azcLgoRo4oukO87g7zDT"{%- endif %} crossorigin="anonymous"></script> + {%- set mathtex_js=config.extra.mathtex_js | default(value="js/mathtex-script-type.min.js") -%} + {%- if mathtex_js %}{%- if mathtex_js is matching("^http[s]?://") %} + <script defer src="{{ mathtex_js | safe }}"{%- if config.extra.integrity | default(value=true) and config.extra.mathtex_js_integrity %} integrity="{{ config.extra.mathtex_js_integrity | safe }}"{%- endif %} crossorigin="anonymous"></script> {%- else %} - <script defer src="{{ get_url(path=config.extra.mathtex_js, trailing_slash=false, cachebust=true) }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path=config.extra.mathtex_js, sha_type=384, base64=true) | safe }}"{%- endif %}></script> + <script defer src="{{ get_url(path=mathtex_js, trailing_slash=false, cachebust=true) }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=mathtex_js, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %}{%- endif %} {%- if config.extra.math_auto_render or page.extra.math_auto_render %} - {%- if config.extra.katex_autorender_js %} - {%- if config.extra.katex_autorender_js is matching("^http[s]?://") %} - <script defer src="{{ config.extra.katex_autorender_js | safe }}"{%- if config.extra.integrity %} integrity="sha384-+XBljXPPiv+OzfbB3cVmLHf4hdUFHlWNZN5spNQ7rmHTXpd7WvJum6fIACpNNfIR"{%- endif %} crossorigin="anonymous"></script> + {%- set katex_autorender_js=config.extra.katex_autorender_js | default(value="js/katex-auto-render.min.js") -%} + {%- if katex_autorender_js %} + {%- if katex_autorender_js is matching("^http[s]?://") %} + <script defer src="{{ katex_autorender_js | safe }}"{%- if config.extra.integrity | default(value=true) and config.extra.katex_autorender_js_integrity %} integrity="{{ config.extra.katex_autorender_js_integrity | safe }}"{%- endif %} crossorigin="anonymous"></script> {%- else %} - <script defer src="{{ get_url(path=config.extra.katex_autorender_js, trailing_slash=false, cachebust=true) }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path=config.extra.katex_autorender_js, sha_type=384, base64=true) | safe }}"{%- endif %}></script> + <script defer src="{{ get_url(path=katex_autorender_js, trailing_slash=false, cachebust=true) }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=katex_autorender_js, sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- endif %} {%- endif %} + {%- set katex_options=config.extra.katex_options | default(value="js/katexoptions.js") -%} + {%- if katex_options %} + <script defer src="{{ get_url(path=katex_options, trailing_slash=false, cachebust=true) }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=katex_options, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} - <script defer src="{{ get_url(path=config.extra.katex_options, trailing_slash=false, cachebust=true) }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_hash(path=config.extra.katex_options, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} {%- endif %} @@ -259,6 +227,10 @@ <link rel="mask-icon" href="{{ get_url(path=config.extra.favicon_mask, trailing_slash=false) | safe }}" color="{{ config.extra.favicon_mask_color }}" /> {%- endif %} + {%- if config.extra.favicon_svg %} + <link rel="icon" type="image/svg+xml" href="{{ get_url(path=config.extra.favicon_svg, trailing_slash=false) | safe }}" /> + {%- endif %} + {%- if config.extra.favicon180 %} <link rel="apple-touch-icon" sizes="180x180" href="{{ get_url(path=config.extra.favicon180, trailing_slash=false) | safe }}" /> {%- endif %} @@ -289,7 +261,7 @@ {#- page_images: using for the blog single template page -#} {#- page_section: the blog single template page have to pass the parameter -#} {#- is_404: using for the 404.html template -#} -{%- macro seo( config, title="", title_addition="", description="", type="website", is_home=false, is_404=false, is_page=false, page_images="", page_section="", created_time="2021-07-04T07:07:00-07:00", updated_time="2021-07-04T07:07:00-07:00" ) %} +{%- macro seo( config, title="", title_addition="", description="", type="website", is_home=false, is_404=false, is_page=false, page_images="", page_section="", created_time="2023-05-15T07:07:00-07:00", updated_time="2023-05-15T07:07:00-07:00" ) %} {%- if is_404 -%} <meta name="robots" content="noindex, follow" /> {%- else -%} @@ -321,9 +293,11 @@ <meta name="description" content="{{ config.description }}" /> {%- endif %} <link rel="canonical" href="{{ page_url | safe }}" /> -{%- if page.extra.keywords %} +{%- if page.extra.keywords and config.extra.keywords %} <meta name="keywords" content="{{ page.extra.keywords }}, {{ config.extra.keywords }}" /> -{%- else %} +{%- elif page.extra.keywords %} + <meta name="keywords" content="{{ page.extra.keywords }}" /> +{%- elif config.extra.keywords %} <meta name="keywords" content="{{ config.extra.keywords }}" /> {%- endif %} @@ -410,9 +384,9 @@ <meta property="og:updated_time" content="{{ updated_time }}" /> {%- endif %} -{%- if config.extra.social.twitter %} - <meta name="twitter:site" content="@{{ config.extra.twitter }}" /> - <meta name="twitter:creator" content="@{{ config.extra.twitter }}" /> +{%- if config.extra.twitter_meta %} + <meta name="twitter:site" content="@{{ config.extra.twitter_meta }}" /> + <meta name="twitter:creator" content="@{{ config.extra.twitter_meta }}" /> {%- endif %} diff --git a/templates/macros/macros.html b/templates/macros/macros.html index 2c17530..f994bdb 100644 --- a/templates/macros/macros.html +++ b/templates/macros/macros.html @@ -1,9 +1,9 @@ {%- macro title_post(page, config) %} - <h1><a href="{{ page.permalink | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ page.title }}</a></h1> + <h1><a href="{{ page.permalink | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ page.title }}</a></h1> {%- endmacro title_post %} {%- macro meta_post(page, config) %} - <span{%- if config.extra.meta_post.size %} class="{{ config.extra.meta_post.size }}"{% endif %}> + <span{%- if config.extra.meta_post.size %} class="{{ config.extra.meta_post.size }}"{% endif %}> {#- Author #} {%- if page.taxonomies.authors and config.taxonomies %} @@ -24,7 +24,7 @@ {#- divider #} {%- if config.extra.meta_post.author %} - {%- if config.extra.meta_post.readtime or config.extra.meta_post.date or config.extra.meta_post.categories_tags %} + {%- if config.extra.meta_post.readtime or config.extra.meta_post.date or config.extra.meta_post.updated or config.extra.meta_post.categories_tags %} {%- if config.extra.meta_post.divider %}<span class="hpad">{{ config.extra.meta_post.divider | safe }}</span>{%- else %} {%- endif %} {%- endif %} {%- endif %} @@ -32,20 +32,42 @@ {#- ReadTime #} {%- if config.extra.meta_post.readtime %} {%- if config.extra.icon_read %}<i class="{{ config.extra.icon_read }}"></i> {% endif %} {{ page.reading_time }} {{ config.extra.meta_post.readstring | default(value="min") }} {#- divider #} - {%- if config.extra.meta_post.date or config.extra.meta_post.categories_tags %} + {%- if config.extra.meta_post.date or config.extra.meta_post.updated or config.extra.meta_post.categories_tags %} {%- if config.extra.meta_post.divider %}<span class="hpad">{{ config.extra.meta_post.divider | safe }}</span>{%- else %} {%- endif %}{%- endif %}{%- endif %} {#- Date #} - {%- if config.extra.meta_post.date %} {%- if config.extra.icon_date %}<i class="{{ config.extra.icon_date }}"></i> {% endif %} {{ page.date | date(format="%B %d, %Y") }} + {%- if config.extra.meta_post.date %} {%- if config.extra.icon_date %}<i class="{{ config.extra.icon_date }}"></i> {% endif %} + {%- if config.extra.date_locale %} + {%- if lang != config.default_language -%} + {%- set lang_locale = trans(key="date_locale" | safe, lang=lang) -%} + {%- else -%} + {%- set lang_locale = config.extra.date_locale -%} + {%- endif -%} + {{ page.date | date(format="%B %d, %Y", locale=lang_locale) }} + {%- else %} {{ page.date | date(format="%B %d, %Y") }} {%- endif %} + {#- divider #} + {%- if config.extra.meta_post.updated or config.extra.meta_post.categories_tags %} + {%- if config.extra.meta_post.divider %}<span class="hpad">{{ config.extra.meta_post.divider | safe }}</span>{%- else %} {%- endif %}{%- endif %}{% endif %} + + {#- Updated #} + {%- if config.extra.meta_post.updated and page.updated %} {%- if config.extra.icon_date %}<i class="{{ config.extra.icon_date }}"></i> {% endif -%} + {%- if lang != config.default_language %} {{ trans(key="Updated" | safe, lang=lang) }}{% else %} Updated{% endif %}: + {%- if config.extra.date_locale %} + {%- if lang != config.default_language -%} + {%- set lang_locale = trans(key="date_locale" | safe, lang=lang) -%} + {%- else -%} + {%- set lang_locale = config.extra.date_locale -%} + {%- endif %} {{ page.updated | date(format="%B %d, %Y", locale=lang_locale) }} + {%- else %} {{ page.updated | date(format="%B %d, %Y") }} {%- endif %} {#- divider #} {%- if config.extra.meta_post.categories_tags %} {%- if config.extra.meta_post.divider %}<span class="hpad">{{ config.extra.meta_post.divider | safe }}</span>{%- else %} {%- endif %}{%- endif %}{% endif %} {#- Categories #} - {%- if page.taxonomies.categories %} {%- if config.extra.icon_info %}<i class="{{ config.extra.icon_info }}"></i> {% endif %} [{% for cat in page.taxonomies.categories %}<a href="{{ get_taxonomy_url(kind='categories', name=cat) | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ cat }}</a>{% endfor %}]{% endif %} + {%- if page.taxonomies.categories %} {%- if config.extra.icon_info %}<i class="{{ config.extra.icon_info }}"></i> {% endif %} [{% for cat in page.taxonomies.categories %}<a href="{{ get_taxonomy_url(kind='categories', name=cat, lang=lang) | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ cat }}</a>{% endfor %}]{% endif %} {#- Tags #} - {%- if page.taxonomies.tags %} {%- for tag in page.taxonomies.tags %} #<a href="{{ get_taxonomy_url(kind='tags', name=tag) | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ tag }}</a> {% endfor -%}{%- endif %}</span> + {%- if page.taxonomies.tags %} {%- for tag in page.taxonomies.tags %} #<a href="{{ get_taxonomy_url(kind='tags', name=tag, lang=lang) | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ tag }}</a> {% endfor -%}{%- endif %}</span> {%- endmacro meta_post %} {%- macro title_index(page, config) %} @@ -60,7 +82,7 @@ {%- if page.taxonomies.authors and config.taxonomies %} {%- for author in page.taxonomies.authors %} {%- if author_flag %}, {% endif %} - <a href="{{ get_taxonomy_url(kind='authors', name=author) | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ author }}</a> + <a href="{{ get_taxonomy_url(kind='authors', name=author, lang=lang) | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ author }}</a> {%- set_global author_flag = true %} {%- endfor %} {%- elif page.extra.authors and config.extra.meta_index.author %} @@ -75,7 +97,7 @@ {#- divider #} {%- if config.extra.meta_index.author %} - {%- if config.extra.meta_index.readtime or config.extra.meta_index.date or config.extra.meta_index.categories_tags %} + {%- if config.extra.meta_index.readtime or config.extra.meta_index.date or config.extra.meta_index.updated or config.extra.meta_index.categories_tags %} {%- if config.extra.meta_index.divider %}<span class="hpad">{{ config.extra.meta_index.divider | safe }}</span>{%- else %} {%- endif %} {%- endif %} {%- endif %} @@ -83,31 +105,69 @@ {#- ReadTime #} {%- if config.extra.meta_index.readtime %} {%- if config.extra.icon_read %}<i class="{{ config.extra.icon_read }}"></i> {% endif %} {{ page.reading_time }} {{ config.extra.meta_index.readstring | default(value="min") }} {#- divider #} - {%- if config.extra.meta_index.date or config.extra.meta_index.categories_tags %} + {%- if config.extra.meta_index.date or config.extra.meta_index.updated or config.extra.meta_index.categories_tags %} {%- if config.extra.meta_index.divider %}<span class="hpad">{{ config.extra.meta_index.divider | safe }}</span>{%- else %} {%- endif %}{%- endif %}{%- endif %} {#- Date #} - {%- if config.extra.meta_index.date %} {%- if config.extra.icon_date %}<i class="{{ config.extra.icon_date }}"></i> {% endif %} {{ page.date | date(format="%B %d, %Y") }} + {%- if config.extra.meta_index.date %} {%- if config.extra.icon_date %}<i class="{{ config.extra.icon_date }}"></i> {% endif %} + {%- if config.extra.date_locale %} + {%- if lang != config.default_language -%} + {%- set lang_locale = trans(key="date_locale" | safe, lang=lang) -%} + {%- else -%} + {%- set lang_locale = config.extra.date_locale -%} + {%- endif -%} + {{ page.date | date(format="%B %d, %Y", locale=lang_locale) }} + {%- else %} {{ page.date | date(format="%B %d, %Y") }} {%- endif %} + {#- divider #} + {%- if config.extra.meta_index.updated or config.extra.meta_index.categories_tags %} + {%- if config.extra.meta_index.divider %}<span class="hpad">{{ config.extra.meta_index.divider | safe }}</span>{%- else %} {%- endif %}{%- endif %}{% endif %} + + {#- Updated #} + {%- if config.extra.meta_index.updated and page.updated %} {%- if config.extra.icon_date %}<i class="{{ config.extra.icon_date }}"></i> {% endif -%} + {%- if lang != config.default_language %} {{ trans(key="Updated" | safe, lang=lang) }}{% else %} Updated{% endif %}: + {%- if config.extra.date_locale %} + {%- if lang != config.default_language -%} + {%- set lang_locale = trans(key="date_locale" | safe, lang=lang) -%} + {%- else -%} + {%- set lang_locale = config.extra.date_locale -%} + {%- endif %} {{ page.updated | date(format="%B %d, %Y", locale=lang_locale) }} + {%- else %} {{ page.updated | date(format="%B %d, %Y") }} {%- endif %} + {#- divider #} {%- if config.extra.meta_index.categories_tags %} {%- if config.extra.meta_index.divider %}<span class="hpad">{{ config.extra.meta_index.divider | safe }}</span>{%- else %} {%- endif %}{%- endif %}{% endif %} {#- Categories #} - {%- if page.taxonomies.categories %} {%- if config.extra.icon_info %}<i class="{{ config.extra.icon_info }}"></i> {% endif %} [{% for cat in page.taxonomies.categories %}<a href="{{ get_taxonomy_url(kind='categories', name=cat) | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ cat }}</a>{% endfor %}]{% endif %} + {%- if page.taxonomies.categories %} {%- if config.extra.icon_info %}<i class="{{ config.extra.icon_info }}"></i> {% endif %} [{% for cat in page.taxonomies.categories %}<a href="{{ get_taxonomy_url(kind='categories', name=cat, lang=lang) | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ cat }}</a>{% endfor %}]{% endif %} {#- Tags #} - {%- if page.taxonomies.tags %} {%- for tag in page.taxonomies.tags %} #<a href="{{ get_taxonomy_url(kind='tags', name=tag) | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ tag }}</a> {% endfor -%}{%- endif %}</span> + {%- if page.taxonomies.tags %} {%- for tag in page.taxonomies.tags %} #<a href="{{ get_taxonomy_url(kind='tags', name=tag, lang=lang) | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ tag }}</a> {% endfor -%}{%- endif %}</span> {%- endmacro meta_index %} -{%- macro footer(page) %} -{%- if page.reading_time %} -{%- if page.reading_time > 2 %} -<p><b><a href="#">Back to top</a></b></p> -{%- endif %} -{%- endif %} +{%- macro footer(page, config) %} + {%- if page.reading_time and page.reading_time > 2 %} + <p><b><a href="#">Back to top</a></b></p> + {%- endif %} + {#- prev/next content page nextprev title pagination #} + {%- if not config.extra.hide_page_nextprev_titles | default(value=false) %} + {%- if page.lower or page.higher %} + <nav> + <div> + {%- if page.lower %} + <a href="{{ page.lower.permalink | safe }}">‹ {{ page.lower.title | truncate(length=100) }}</a> + {%- endif %} + </div> + <div> + {%- if page.higher %} + <a href="{{ page.higher.permalink | safe }}"> {{ page.higher.title | truncate(length=100) }} ›</a> + {%- endif %} + </div> + </nav> + {%- endif %} + {%- endif %} {%- endmacro footer %} @@ -141,75 +201,75 @@ {%- endif %} {%- endif %} <nav> - <ul> + {%- set icon_first=config.extra.icon_first | default(value="svgs svgh angll") -%} + {%- set icon_prev=config.extra.icon_prev | default(value="svgs svgh angl") -%} + {%- set icon_next=config.extra.icon_next | default(value="svgs svgh angr") -%} + {%- set icon_last=config.extra.icon_last | default(value="svgs svgh angrr") -%} {%- if paginator.previous -%} - <li><a class="on outp" href="{{ paginator.first | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}" title="First Page"> - {%- if config.extra.icon_first -%}<i class="{{ config.extra.icon_first }}" alt="First Page"></i> + <a class="on outp" href="{{ paginator.first | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}" title="First Page"> + {%- if icon_first -%}<i class="{{ icon_first }}" alt="First Page"></i> {%- else -%}❰ {%- endif -%} - </a></li> + </a> {%- else -%} - <li><span class="off outp"> - {%- if config.extra.icon_first -%}<i class="{{ config.extra.icon_first }}" alt="First Page"></i> + <span class="off outp"> + {%- if icon_first -%}<i class="{{ icon_first }}" alt="First Page"></i> {%- else -%}❰ {%- endif -%} - </span></li> + </span> {%- endif -%} {%- if paginator.previous -%} - <li><a class="on outp" href="{{ paginator.previous | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}" title="Previous Page"> - {%- if config.extra.icon_prev -%}<i class="{{ config.extra.icon_prev }}" alt="Previous Page"></i> + <a class="on outp" href="{{ paginator.previous | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}" title="Previous Page"> + {%- if icon_prev -%}<i class="{{ icon_prev }}" alt="Previous Page"></i> {%- else -%}❬ {%- endif -%} - </a></li> + </a> {%- else -%} - <li><span class="off outp"> - {%- if config.extra.icon_prev -%}<i class="{{ config.extra.icon_prev }}" alt="Previous Page"></i> + <span class="off outp"> + {%- if icon_prev -%}<i class="{{ icon_prev }}" alt="Previous Page"></i> {%- else -%}❬ {%- endif -%} - </span></li> + </span> {%- endif -%} {%- for i in range(start=start, end=end+1) -%} - <li class="inp"> {%- if i == paginator.current_index -%} - <a class="on cnav" href="#">{{i}}</a> + <a class="inp on cnav" href="#">{{i}}</a> {%- elif i > 1 -%} - <a class="on" href="{{ paginator.base_url | safe }}{{ i ~ '/' }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{i}}</a> + <a class="inp on" href="{{ paginator.base_url | safe }}{{ i ~ '/' }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{i}}</a> {%- else -%} - <a class="on" href="{{ paginator.first | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ i }}</a> + <a class="inp on" href="{{ paginator.first | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ i }}</a> {%- endif -%} - </li> {%- endfor -%} {%- if paginator.next -%} - <li><a class="on outp" href="{{ paginator.next | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}" title="Next Page"> - {%- if config.extra.icon_next -%}<i class="{{ config.extra.icon_next }}" alt="Next Page"></i> + <a class="on outp" href="{{ paginator.next | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}" title="Next Page"> + {%- if icon_next -%}<i class="{{ icon_next }}" alt="Next Page"></i> {%- else -%}❭ {%- endif -%} - </a></li> + </a> {%- else -%} - <li><span class="off outp"> - {%- if config.extra.icon_next -%}<i class="{{ config.extra.icon_next }}" alt="Next Page"></i> + <span class="off outp"> + {%- if icon_next -%}<i class="{{ icon_next }}" alt="Next Page"></i> {%- else -%}❭ {%- endif -%} - </span></li> + </span> {%- endif -%} {%- if paginator.next -%} - <li><a class="on outp" href="{{ paginator.last | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}" title="Last Page"> - {%- if config.extra.icon_last -%}<i class="{{ config.extra.icon_last }}" alt="Last Page"></i> + <a class="on outp" href="{{ paginator.last | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}" title="Last Page"> + {%- if icon_last -%}<i class="{{ icon_last }}" alt="Last Page"></i> {%- else -%}❱ {%- endif -%} - </a></li> + </a> {%- else -%} - <li><span class="off outp"> - {%- if config.extra.icon_last -%}<i class="{{ config.extra.icon_last }}" alt="Last Page"></i> + <span class="off outp"> + {%- if icon_last -%}<i class="{{ icon_last }}" alt="Last Page"></i> {%- else -%}❱ {%- endif -%} - </span></li> + </span> {%- endif -%} - </ul> </nav> {%- endif %} {%- endmacro %} diff --git a/templates/macros/social.html b/templates/macros/social.html index 36be051..1221ce7 100644 --- a/templates/macros/social.html +++ b/templates/macros/social.html @@ -1,59 +1,58 @@ -{%- macro social_links(social_config, config) %} - <nav> - <ul> -{%- set base_url = get_url(path="", lang=lang) -%} - {%- if config.generate_feed -%}{%- if config.extra.social.feed -%} - <li><a href="{{ get_url(path=config.feed_filename, trailing_slash=false) | safe }}" target="_blank" title="Atom/RSS Feed"><i type="Button" class="svg rss" title="Atom/RSS Feed"></i></a></li>{% endif -%}{% endif -%} - {%- if social_config.mail -%} - {%- if social_config.mail_encode -%} - {%- set base64_email = social_config.mail -%} - <li class="js"><a class="m-protected" href="#{{ base64_email | base64_encode }}" target="_blank" title="Mail"><i type="Button" class="svg mail" title="Mail"></i></a></li> +{%- macro social_links(config) %} + <nav><div> + {%- if config.generate_feed and config.extra.feed -%} + <a href="{{ get_url(path=config.feed_filename, trailing_slash=false, lang=lang) | safe }}" target="_blank" title="Atom/RSS Feed"><i type="Button" class="svg rss" title="Atom/RSS Feed"></i></a>{% endif -%} + {%- if config.extra.mail -%} + {%- if config.extra.mail_encode | default(value=true) -%} + {%- set base64_email = config.extra.mail -%} + <a class="js m-protected" href="#{{ base64_email | base64_encode }}" target="_blank" title="Mail"><i type="Button" class="svg mail" title="Mail"></i></a> {%- else -%} - <li><a href="mailto:{{ social_config.mail }}" target="_blank" title="Mail"><i type="Button" class="svg mail" title="Mail"></i></a></li> + <a href="mailto:{{ config.extra.mail }}" target="_blank" title="Mail"><i type="Button" class="svg mail" title="Mail"></i></a> {%- endif -%} {% endif -%} - {%- if social_config.mastodon -%} - <li><a href="{{ social_config.mastodon | safe }}" target="_blank" title="Mastodon" rel="me"><i type="Button" class="svg mastodon" title="Mastodon"></i></a></li>{% endif -%} - {%- if social_config.element -%} - <li><a href="https://{{ social_config.element }}/" target="_blank" title="Element"><i type="Button" class="svg element" title="Element"></i></a></li>{% endif -%} - {%- if social_config.matrix -%} - <li><a href="https://{{ social_config.matrix }}/" target="_blank" title="Matrix"><i type="Button" class="svg matrix" title="Matrix"></i></a></li>{% endif -%} - {%- if social_config.twitter -%} - <li><a href="https://twitter.com/{{ social_config.twitter }}/" target="_blank" title="Twitter"><i type="Button" class="svg twitter" title="Twitter"></i></a></li>{% endif -%} - {%- if social_config.facebook -%} - <li><a href="https://www.facebook.com/{{ social_config.facebook }}/" target="_blank" title="Facebook"><i type="Button" class="svg facebook" title="Facebook"></i></a></li>{% endif -%} - {%- if social_config.linkedin -%} - <li><a href="https://www.linkedin.com/in/{{ social_config.linkedin }}/" target="_blank" title="LinkedIn"><i type="Button" class="svg linkedin" title="LinkedIn"></i></a></li>{% endif -%} - {%- if social_config.researchgate -%} - <li><a href="https://www.researchgate.net/profile/{{ social_config.researchgate }}/" target="_blank" title="ResearchGate"><i type="Button" class="svg researchgate" title="ResearchGate"></i></a></li>{% endif -%} - {%- if social_config.codeberg -%} - <li><a href="https://codeberg.org/{{ social_config.codeberg }}/" target="_blank" title="Codeberg"><i type="Button" class="svg codeberg" title="Codeberg"></i></a></li>{% endif -%} - {%- if social_config.gitlab -%} - <li><a href="https://gitlab.com/{{ social_config.gitlab }}/" target="_blank" title="Gitlab"><i type="Button" class="svg gitlab" title="Gitlab"></i></a></li>{% endif -%} - {%- if social_config.github -%} - <li><a href="https://github.com/{{ social_config.github }}/" target="_blank" title="Github"><i type="Button" class="svg github" title="Github"></i></a></li>{% endif -%} - {%- if social_config.bitbucket -%} - <li><a href="https://bitbucket.org/{{ social_config.bitbucket }}/" target="_blank" title="Bitbucket"><i type="Button" class="svg bitbucket" title="Bitbucket"></i></a></li>{% endif -%} - {%- if social_config.python -%} - <li><a href="https://pypi.org/user/{{ social_config.python }}/" target="_blank" title="Python"><i type="Button" class="svg python" title="Python"></i></a></li>{% endif -%} - {%- if social_config.docker -%} - <li><a href="https://hub.docker.com/u/{{ social_config.docker }}/" target="_blank" title="Docker"><i type="Button" class="svg docker" title="Docker"></i></a></li>{% endif -%} - {%- if social_config.stack -%} - <li><a href="https://stackoverflow.com/users/{{ social_config.stack }}/" target="_blank" title="Stack"><i type="Button" class="svg stack" title="Stack"></i></a></li>{% endif -%} - {%- if social_config.instagram -%} - <li><a href="https://www.instagram.com/{{ social_config.instagram }}/" target="_blank" title="Instagram"><i type="Button" class="svg instagram" title="Instagram"></i></a></li>{% endif -%} - {%- if social_config.pinterest -%} - <li><a href="https://www.pinterest.com/{{ social_config.pinterest }}/" target="_blank" title="Pinterest"><i type="Button" class="svg pinterest" title="Pinterest"></i></a></li>{% endif -%} - {%- if social_config.twitch -%} - <li><a href="https://www.twitch.tv/{{ social_config.twitch }}/" target="_blank" title="Twitch"><i type="Button" class="svg twitch" title="Twitch"></i></a></li>{% endif -%} - {%- if social_config.discord -%} - <li><a href="https://discord.com/{{ social_config.discord }}/" target="_blank" title="Discord"><i type="Button" class="svg discord" title="Discord"></i></a></li>{% endif -%} - {%- if social_config.youtube -%} - <li><a href="https://www.youtube.com/{{ social_config.youtube }}" target="_blank" title="YouTube"><i type="Button" class="svg youtube" title="YouTube"></i></a></li>{% endif -%} - {%- if social_config.buymeacoffee -%} - <li><a href="https://www.buymeacoffee.com/{{ social_config.buymeacoffee }}/" target="_blank" title="Buy Me A Coffee"><i type="Button" class="svg buymeacoffee" title="Buy Me A Coffee"></i></a></li>{% endif -%} - {%- if social_config.github_sponsor -%} - <li><a href="https://github.com/sponsors/{{ social_config.github_sponsor }}/" target="_blank" title="GitHub Sponsor"><i type="Button" class="svg github-sponsor" title="GitHub Sponsor"></i></a></li>{% endif -%} - </ul> - </nav> + {%- if config.extra.mastodon -%} + <a href="{{ config.extra.mastodon | safe }}" target="_blank" title="Mastodon" rel="me"><i type="Button" class="svg mastodon" title="Mastodon"></i></a>{% endif -%} + {%- if config.extra.element -%} + <a href="https://{{ config.extra.element }}/" target="_blank" title="Element"><i type="Button" class="svg element" title="Element"></i></a>{% endif -%} + {%- if config.extra.matrix -%} + <a href="https://{{ config.extra.matrix }}/" target="_blank" title="Matrix"><i type="Button" class="svg matrix" title="Matrix"></i></a>{% endif -%} + {%- if config.extra.twitter -%} + <a href="https://twitter.com/{{ config.extra.twitter }}/" target="_blank" title="Twitter"><i type="Button" class="svg twitter" title="Twitter"></i></a>{% endif -%} + {%- if config.extra.facebook -%} + <a href="https://www.facebook.com/{{ config.extra.facebook }}/" target="_blank" title="Facebook"><i type="Button" class="svg facebook" title="Facebook"></i></a>{% endif -%} + {%- if config.extra.linkedin -%} + <a href="https://www.linkedin.com/in/{{ config.extra.linkedin }}/" target="_blank" title="LinkedIn"><i type="Button" class="svg linkedin" title="LinkedIn"></i></a>{% endif -%} + {%- if config.extra.researchgate -%} + <a href="https://www.researchgate.net/profile/{{ config.extra.researchgate }}/" target="_blank" title="ResearchGate"><i type="Button" class="svg researchgate" title="ResearchGate"></i></a>{% endif -%} + {%- if config.extra.codeberg -%} + <a href="https://codeberg.org/{{ config.extra.codeberg }}/" target="_blank" title="Codeberg"><i type="Button" class="svg codeberg" title="Codeberg"></i></a>{% endif -%} + {%- if config.extra.gitlab -%} + <a href="https://gitlab.com/{{ config.extra.gitlab }}/" target="_blank" title="Gitlab"><i type="Button" class="svg gitlab" title="Gitlab"></i></a>{% endif -%} + {%- if config.extra.github -%} + <a href="https://github.com/{{ config.extra.github }}/" target="_blank" title="Github"><i type="Button" class="svg github" title="Github"></i></a>{% endif -%} + {%- if config.extra.bitbucket -%} + <a href="https://bitbucket.org/{{ config.extra.bitbucket }}/" target="_blank" title="Bitbucket"><i type="Button" class="svg bitbucket" title="Bitbucket"></i></a>{% endif -%} + {%- if config.extra.python -%} + <a href="https://pypi.org/user/{{ config.extra.python }}/" target="_blank" title="Python"><i type="Button" class="svg python" title="Python"></i></a>{% endif -%} + {%- if config.extra.docker -%} + <a href="https://hub.docker.com/u/{{ config.extra.docker }}/" target="_blank" title="Docker"><i type="Button" class="svg docker" title="Docker"></i></a>{% endif -%} + {%- if config.extra.stack -%} + <a href="https://stackoverflow.com/users/{{ config.extra.stack }}/" target="_blank" title="Stack"><i type="Button" class="svg stack" title="Stack"></i></a>{% endif -%} + {%- if config.extra.instagram -%} + <a href="https://www.instagram.com/{{ config.extra.instagram }}/" target="_blank" title="Instagram"><i type="Button" class="svg instagram" title="Instagram"></i></a>{% endif -%} + {%- if config.extra.pinterest -%} + <a href="https://www.pinterest.com/{{ config.extra.pinterest }}/" target="_blank" title="Pinterest"><i type="Button" class="svg pinterest" title="Pinterest"></i></a>{% endif -%} + {%- if config.extra.twitch -%} + <a href="https://www.twitch.tv/{{ config.extra.twitch }}/" target="_blank" title="Twitch"><i type="Button" class="svg twitch" title="Twitch"></i></a>{% endif -%} + {%- if config.extra.discord -%} + <a href="https://discord.com/{{ config.extra.discord }}/" target="_blank" title="Discord"><i type="Button" class="svg discord" title="Discord"></i></a>{% endif -%} + {%- if config.extra.youtube -%} + <a href="https://www.youtube.com/{{ config.extra.youtube }}" target="_blank" title="YouTube"><i type="Button" class="svg youtube" title="YouTube"></i></a>{% endif -%} + {%- if config.extra.kofi -%} + <a href="https://www.ko-fi.com/{{ config.extra.kofi }}/" target="_blank" title="Support me on Ko-fi"><i type="Button" class="svg kofi" title="Support me on Ko-fi"></i></a>{% endif -%} + {%- if config.extra.buymeacoffee -%} + <a href="https://www.buymeacoffee.com/{{ config.extra.buymeacoffee }}/" target="_blank" title="Buy Me A Coffee"><i type="Button" class="svg buymeacoffee" title="Buy Me A Coffee"></i></a>{% endif -%} + {%- if config.extra.github_sponsor -%} + <a href="https://github.com/sponsors/{{ config.extra.github_sponsor }}/" target="_blank" title="GitHub Sponsor"><i type="Button" class="svg github-sponsor" title="GitHub Sponsor"></i></a>{% endif -%} + </div></nav> {%- endmacro %} diff --git a/templates/page.html b/templates/page.html index 1c21d67..e002b31 100644 --- a/templates/page.html +++ b/templates/page.html @@ -30,6 +30,12 @@ {{- macros_head::seo(config=config, title=title, title_addition=title_addition, description=description, type="article", is_page=true, created_time=created_time, updated_time=updated_time, page_section=page_section) }} {%- endblock seo %} +{%- block comments_init %} + {%- if config.extra.comments.hyvor %} + <script async src="https://talk.hyvor.com/embed/embed.js" type="module"></script> + {%- endif %} +{%- endblock comments_init %} + {%- block content %} <article> {{- macros::title_post(page=page, config=config) }} @@ -39,7 +45,7 @@ {{- macros::meta_post(page=page, config=config) }} {%- endif %}{%- endif %} - {{ page.content | safe }} +{{ page.content | safe }} {%- if config.extra.meta_post.position %} {%- if config.extra.meta_post.position == "bottom" or config.extra.meta_post.position == "both" %} @@ -47,7 +53,7 @@ {%- endif %}{%- endif %} {%- block page_footer %} - {{- macros::footer(page=page) }} + {{- macros::footer(page=page, config=config) }} {%- endblock page_footer %} {%- block comments_body %} @@ -61,17 +67,17 @@ {%- set toc = page.toc %} {%- endif %} {%- if toc %} - <div class="toc" aria-hidden="true"> + <div class="toc"> <div class="toc-sticky"> - <h3>Index</h3> + <h3>{%- if lang != config.default_language %}{{ trans(key="Index" | safe, lang=lang) }}{% else %}Index{% endif %}</h3> {%- for h in toc %} <div class="toc-item"> - <a class="subtext" href="{{h.permalink | safe}}">{{ h.title }}</a> + <a class="subtext" href="#{{h.id | safe}}">{{ h.title }}</a> </div> {%- if h.children %} {%- for h2 in h.children %} <div class="toc-item-child"> - <a class="subtext" href="{{h2.permalink | safe}}"><small>- {{ h2.title }}</small></a> + <a class="subtext" href="#{{h2.id | safe}}"><small>- {{ h2.title }}</small></a> </div> {%- endfor %} {%- endif %} @@ -87,8 +93,9 @@ {%- if page.reading_time %} {%- if page.reading_time > 2 %} +{%- set icon_top=config.extra.icon_top | default(value="svgs svgh angu") -%} <span class="topout"> -<span class="topleft"> </span><a href="#" class="top" title="Back to Top">{%- if config.extra.icon_top %}<i class="{{ config.extra.icon_top }}"></i>{%- else %}⋏{%- endif %}</a> +<span class="topleft"> </span><a href="#" class="top" title="Back to Top">{%- if icon_top %}<i class="{{ icon_top }}"></i>{%- else %}⋏{%- endif %}</a> </span> {%- endif %} {%- endif %} diff --git a/templates/pages.html b/templates/pages.html index 87c9adb..4ef44f5 100644 --- a/templates/pages.html +++ b/templates/pages.html @@ -26,6 +26,7 @@ {%- block content %} <div> - {{ page.content | safe }} + +{{ page.content | safe }} </div> {%- endblock content %} diff --git a/templates/posts.html b/templates/posts.html deleted file mode 100644 index d4fc9e4..0000000 --- a/templates/posts.html +++ /dev/null @@ -1,30 +0,0 @@ -{# This Page Shows the Posts Grouped by Year: example.com/posts/ #} - -{% extends "base.html" %} - -{%- block seo %} - {{- super() }} - {%- set title = "Posts" %} - - {%- if config.title %} - {%- set title_addition = title_separator ~ config.title %} - {%- else %} - {%- set title_addition = "" %} - {%- endif %} - - {%- set description = config.description %} - - {{- macros_head::seo(config=config, title=title, title_addition=title_addition, description=description, is_home=true) }} -{%- endblock seo %} - -{%- block content %} -{%- set section_item = get_section(path="_index.md") %} - <div> - {%- for year, posts in section_item.pages | group_by(attribute="year") %} - <h2>{{ year }}</h2> - {%- for post in posts %} - <p><a href="{{ post.permalink | safe }}">{{ post.title }}</a> - <time datetime="{{ post.date }}">{{ post.date | date(format="%F") }}</time></p> - {%- endfor %} - {%- endfor %} - </div> -{%- endblock content %} diff --git a/templates/robots.txt b/templates/robots.txt index 766e67f..7977154 100644 --- a/templates/robots.txt +++ b/templates/robots.txt @@ -1,4 +1,9 @@ +{%- if config.extra.dev %} +User-Agent: * +Disallow: / +{%- else %} Sitemap: {{ get_url(path="sitemap.xml", trailing_slash=false) }} User-Agent: * Allow: / Host: {{ get_url(path="/", trailing_slash=false) }} +{%- endif %} diff --git a/templates/shortcodes/image.html b/templates/shortcodes/image.html index 8452ce9..4f9d3de 100644 --- a/templates/shortcodes/image.html +++ b/templates/shortcodes/image.html @@ -3,5 +3,5 @@ {% set type = source | split(pat=".") | last -%} <source srcset="{{ config.base_url | safe}}{{ page.path | safe }}{{ source | safe }}" type="{{ 'img/' ~ type }}" /> {% endfor -%} - <img src="{{ fpath }}" alt="{{ falt | default(value='Image') }}"{% if fw %} width="{{fw}}"{% endif %}{% if fh %} height="{{fh}}"{% endif %} /> + <img src="{{ fpath }}" alt="{{ falt | default(value='Image') }}"{% if fw %} width="{{fw}}"{% endif %}{% if fh %} height="{{fh}}"{% endif %} loading="lazy" /> </picture> diff --git a/templates/shortcodes/img.html b/templates/shortcodes/img.html index cf2a562..f23f783 100644 --- a/templates/shortcodes/img.html +++ b/templates/shortcodes/img.html @@ -24,5 +24,8 @@ {%- endif %} {%- set img = src | split(pat="/") | last %} -{%- set name = img | split(pat=".") | first %} -<img src="{{ path | safe }}{{ img | safe }}"{% if class %} class="{{class}}"{% endif %}{% if alt %} alt="{{alt}}"{% endif %}{% if w %} width="{{w}}"{% endif %}{% if h %} height="{{h}}"{% endif %} /> + +{%- if not alt %} + {%- set alt = img | split(pat=".") | first %} +{%- endif %} +<img src="{{ path | safe }}{{ img | safe }}"{% if class %} class="{{class}}"{% endif %}{% if alt %} alt="{{alt}}"{% endif %}{% if w %} width="{{w}}"{% endif %}{% if h %} height="{{h}}"{% endif %} loading="lazy" /> diff --git a/templates/shortcodes/imgswap.html b/templates/shortcodes/imgswap.html index f8c983c..4397b29 100644 --- a/templates/shortcodes/imgswap.html +++ b/templates/shortcodes/imgswap.html @@ -25,8 +25,11 @@ {%- endif %} {%- set img = main_src | split(pat="/") | last %} - {%- set name = img | split(pat=".") | first %} - <img src="{{ path | safe }}{{ img | safe }}" class="img-main{% if class %} {{class}}{% endif %}"{% if alt %} alt="{{alt}}"{% endif %}{% if w %} width="{{w}}"{% endif %}{% if h %} height="{{h}}"{% endif %} /> + + {%- if not alt %} + {%- set alt = img | split(pat=".") | first %} + {%- endif %} + <img src="{{ path | safe }}{{ img | safe }}" class="img-main{% if class %} {{class}}{% endif %}"{% if alt %} alt="{{alt}}"{% endif %}{% if w %} width="{{w}}"{% endif %}{% if h %} height="{{h}}"{% endif %} loading="lazy" /> {%- set dirtest = swap_src | trim_start_matches(pat="./") %} {%- if dirtest is containing("/") %} @@ -54,6 +57,9 @@ {%- endif %} {%- set img = swap_src | split(pat="/") | last %} - {%- set name = img | split(pat=".") | first %} - <img src="{{ path | safe }}{{ img | safe }}" class="img-swap{% if class %} {{class}}{% endif %}"{% if alt %} alt="{{alt}}"{% endif %}{% if w %} width="{{w}}"{% endif %}{% if h %} height="{{h}}"{% endif %} /> + + {%- if not alt %} + {%- set alt = img | split(pat=".") | first %} + {%- endif %} + <img src="{{ path | safe }}{{ img | safe }}" class="img-swap{% if class %} {{class}}{% endif %}"{% if alt %} alt="{{alt}}"{% endif %}{% if w %} width="{{w}}"{% endif %}{% if h %} height="{{h}}"{% endif %} loading="lazy" /> </div> diff --git a/templates/shortcodes/streamable.html b/templates/shortcodes/streamable.html new file mode 100644 index 0000000..7df8e9e --- /dev/null +++ b/templates/shortcodes/streamable.html @@ -0,0 +1,3 @@ +<div class="yv{% if class %} {{class}}{% endif %}"> + <iframe src="https://www.streamable.com/e/{{id}}" title="{{title | default(value='Streamable') }}" class="yvi" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> +</div> diff --git a/templates/shortcodes/vimeo.html b/templates/shortcodes/vimeo.html new file mode 100644 index 0000000..0fe3129 --- /dev/null +++ b/templates/shortcodes/vimeo.html @@ -0,0 +1,3 @@ +<div class="yv{% if class %} {{class}}{% endif %}"> + <iframe src="https://player.vimeo.com/video/{{id}}?embedded=true{% if autoplay %}&autoplay=1{% endif %}{% if loop %}&loop=1{% endif %}{% if noautopause %}&autopause=0{% endif %}{% if not cookie %}&dnt=1{% endif %}" title="{{title | default(value='Vimeo') }}" class="yvi" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> +</div> diff --git a/templates/shortcodes/vm.html b/templates/shortcodes/vm.html deleted file mode 100644 index 2dd60e8..0000000 --- a/templates/shortcodes/vm.html +++ /dev/null @@ -1,3 +0,0 @@ -<div class="yv{% if class %} {{class}}{% endif %}"> - <iframe src="https://player.vimeo.com/video/{{id}}?embedded=true{% if autoplay %}&autoplay=1{% endif %}{% if loop %}&loop=1{% endif %}{% if noautopause %}&autopause=0{% endif %}{% if not cookie %}&dnt=1{% endif %}" title="{{title | default(value='Vimeo') }}" class="yvi" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> -</div> diff --git a/templates/shortcodes/youtube.html b/templates/shortcodes/youtube.html new file mode 100644 index 0000000..d07b91b --- /dev/null +++ b/templates/shortcodes/youtube.html @@ -0,0 +1,3 @@ +<div class="yv{% if class %} {{class}}{% endif %}"> + <iframe src="https://www.youtube{% if not cookie %}-nocookie{% endif %}.com/embed/{{id}}{% if playlist %}?list={{playlist}}{% endif %}{% if autoplay %}?autoplay=1{% endif %}" title="{{title | default(value='Youtube') }}" class="yvi" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> +</div> diff --git a/templates/shortcodes/yt.html b/templates/shortcodes/yt.html deleted file mode 100644 index 9fb99dd..0000000 --- a/templates/shortcodes/yt.html +++ /dev/null @@ -1,3 +0,0 @@ -<div class="yv{% if class %} {{class}}{% endif %}"> - <iframe src="https://www.youtube{% if not cookie %}-nocookie{% endif %}.com/embed/{{id}}{% if playlist %}?list={{playlist}}{% endif %}{% if autoplay %}?autoplay=1{% endif %}" title="{{title | default(value='Youtube') }}" class="yvi" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> -</div> diff --git a/templates/tags/list.html b/templates/tags/list.html index 545bf34..a24ef09 100644 --- a/templates/tags/list.html +++ b/templates/tags/list.html @@ -18,13 +18,13 @@ {%- block content %} <div> <div class="c"> - <h1>{{ terms | length }} Tags</h1> - <p>{% for term in terms %} #<a href="#{{ term.name }}">{{ term.name }}</a> {% endfor %}</p> + <h1>{{ terms | length }} {%- if lang != config.default_language %} {{ trans(key="Tags" | safe, lang=lang) }} {% else %} Tags {% endif %}</h1> + <p>{% for term in terms %} #<a href="#{{ term.name }}">{{ term.name }}</a><sup>{{ term.pages | length }}</sup> {% endfor %}</p> </div> {%- for term in terms %} - <h2 id="{{ term.name }}">#<a href="{{ term.permalink | safe }}">{{ term.name }}</a></h2> + <h2 id="{{ term.name }}">#<a href="{{ term.permalink | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ term.name }}</a></h2> {%- for page in term.pages %} - <p><a href="{{ page.permalink | safe }}">{{ page.title }}</a> - <time datetime="{{ page.date }}">{{ page.date | date(format="%F") }}</time></p> + <p><a href="{{ page.permalink | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ page.title }}</a> - <time datetime="{{ page.date }}">{{ page.date | date(format="%F") }}</time></p> {%- endfor %} {%- endfor %} </div> diff --git a/templates/tags/single.html b/templates/tags/single.html index ad8caeb..8984219 100644 --- a/templates/tags/single.html +++ b/templates/tags/single.html @@ -21,7 +21,7 @@ {%- for year, posts in term.pages | group_by(attribute="year") %} <h3>{{ year }}</h3> {%- for page in posts %} - <p><a href="{{ page.permalink | safe }}">{{ page.title }}</a> - <time datetime="{{ page.date }}">{{ page.date | date(format="%F") }}</time></p> + <p><a href="{{ page.permalink | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ page.title }}</a> - <time datetime="{{ page.date }}">{{ page.date | date(format="%F") }}</time></p> {%- endfor %} {%- endfor %} </div> |
