From 08f406c44c861a914c8b63fab454250f8a4c4b36 Mon Sep 17 00:00:00 2001 From: Jieiku Date: Wed, 20 Sep 2023 00:25:21 -0700 Subject: refactor nav, blocks, macros, templates. fix image shortcodes --- templates/404.html | 2 +- templates/archive.html | 8 +- templates/base.html | 122 ++++++----- templates/categories/list.html | 2 +- templates/categories/single.html | 2 +- templates/contact.fr.html | 49 ----- templates/contact.html | 49 ----- templates/index.html | 14 +- templates/macros/head.html | 406 ------------------------------------- templates/macros/macros.html | 33 ++- templates/macros/page.html | 7 - templates/macros/seo.html | 140 +++++++++++++ templates/macros/social.html | 58 ------ templates/page.html | 62 +++--- templates/pages.html | 19 +- templates/partials/head.html | 131 ++++++++++++ templates/partials/head_js.html | 165 +++++++++++++++ templates/partials/social.html | 63 ++++++ templates/shortcodes/img.html | 9 +- templates/shortcodes/imgswap.html | 17 +- templates/shortcodes/showdata.html | 10 + templates/tags/list.html | 2 +- templates/tags/single.html | 2 +- 23 files changed, 675 insertions(+), 697 deletions(-) delete mode 100644 templates/contact.fr.html delete mode 100644 templates/contact.html delete mode 100644 templates/macros/head.html delete mode 100644 templates/macros/page.html create mode 100644 templates/macros/seo.html delete mode 100644 templates/macros/social.html create mode 100644 templates/partials/head.html create mode 100644 templates/partials/head_js.html create mode 100644 templates/partials/social.html (limited to 'templates') diff --git a/templates/404.html b/templates/404.html index 7b7c325..07f32b3 100644 --- a/templates/404.html +++ b/templates/404.html @@ -14,7 +14,7 @@ {%- set description = config.description %} - {{- macros_head::seo(config=config, title=title, title_addition=title_addition, description=description, is_404=true) }} + {{- macros_seo::seo(config=config, title=title, title_addition=title_addition, description=description, is_404=true) }} {%- endblock seo %} {%- block content %} diff --git a/templates/archive.html b/templates/archive.html index 8ac3cfc..e4f7e06 100644 --- a/templates/archive.html +++ b/templates/archive.html @@ -19,13 +19,17 @@ This Template can also be used as the rendering template for Sections, eg: examp {%- set description = config.description %} - {{- macros_head::seo(config=config, title=title, title_addition=title_addition, description=description, is_home=true) }} + {{- macros_seo::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 = "" %} + {%- if section.extra.sec %} + {%- set sec = section.extra.sec ~ "/" %} + {%- else %} + {%- set sec = "" %} + {%- endif %} {%- else %} {%- set langpath = "/" %} {%- if lang != config.default_language %} diff --git a/templates/base.html b/templates/base.html index 8d85516..b3dfec8 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,21 +1,13 @@ -{%- import 'macros/head.html' as macros_head %} -{%- import "macros/social.html" as social_macros %} -{%- import "macros/page.html" as page_macros %} +{%- import 'macros/seo.html' as macros_seo %} {%- import "macros/macros.html" as macros %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} {%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} - {{- macros_head::theme(config=config) }} - {{- macros_head::stylesheets(config=config) }} - - - - {{- macros_head::stylesheets_preload(config=config) }} - {{- macros_head::js(config=config) }} - - {{- macros_head::feed(config=config) }} + {%- include "partials/head.html" %} + + {#- SEO: title, description, etc #} {%- block seo %} {%- if config.extra.title_separator %} {%- set title_separator = " " ~ config.extra.title_separator ~ " " -%} @@ -23,15 +15,11 @@ {%- set title_separator = " | " -%} {%- endif %} {%- endblock seo %} - - - - - {{- macros_head::security(config=config) }} - {{- macros_head::favicons(config=config) }} + {%- block comments_init %} {%- endblock comments_init %} - + + {%- include "partials/head_js.html" %} {%- block header %} @@ -39,7 +27,7 @@ {%- if config.extra.sitedesc %} {%- if config.description %} @@ -119,11 +116,12 @@
{%- endif %}
- {{- social_macros::social_links(config=config) }} + {%- include "partials/social.html" %} {#- Copyright START #} {%- if config.extra.copyright | default(value=true) -%} {%- set current_year = now() | date(format="%Y") %} + {%- set current_year = '' ~ current_year ~ '' %} {%- if config.extra.copyright_override -%} {%- if lang != config.default_language %} diff --git a/templates/categories/list.html b/templates/categories/list.html index bbfb6dc..641fcc4 100644 --- a/templates/categories/list.html +++ b/templates/categories/list.html @@ -14,7 +14,7 @@ {%- set description = config.description %} - {{- macros_head::seo(config=config, title=title, title_addition=title_addition, description=description, is_home=true) }} + {{- macros_seo::seo(config=config, title=title, title_addition=title_addition, description=description, is_home=true) }} {%- endblock seo %} {%- block content %} diff --git a/templates/categories/single.html b/templates/categories/single.html index 7e85232..be219aa 100644 --- a/templates/categories/single.html +++ b/templates/categories/single.html @@ -14,7 +14,7 @@ {%- set description = config.description %} - {{- macros_head::seo(config=config, title=title, title_addition=title_addition, description=description, is_home=true) }} + {{- macros_seo::seo(config=config, title=title, title_addition=title_addition, description=description, is_home=true) }} {%- endblock seo %} {%- block content %} diff --git a/templates/contact.fr.html b/templates/contact.fr.html deleted file mode 100644 index d23569d..0000000 --- a/templates/contact.fr.html +++ /dev/null @@ -1,49 +0,0 @@ -{# 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 %} -
-

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 !

-
-

- - -

-

- - -

-

- - -

-
-

- -

-
-
-{%- endblock content %} diff --git a/templates/contact.html b/templates/contact.html deleted file mode 100644 index 526bb61..0000000 --- a/templates/contact.html +++ /dev/null @@ -1,49 +0,0 @@ -{# This Page Shows the contact page eg: 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 %} -
-

Want to get in touch? Fill out the form below to send me a message and I will get back to you as soon as possible!

-
-

- - -

-

- - -

-

- - -

-
-

- -

-
-
-{%- endblock content %} diff --git a/templates/index.html b/templates/index.html index a364912..705c630 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,6 +1,6 @@ {# -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/ +This Tempalte Shows a paginated page of the Posts of a section with a short summary. +This Template can also be used directly for the index eg: example.com/ or as the rendering template for Sections, eg: example.com/blog/ example.com/software/ #} {%- extends "base.html" %} @@ -26,7 +26,7 @@ This Template can also be used as the rendering template for Sections, eg: examp {%- set description = config.description %} - {{- macros_head::seo(config=config, title=title, title_addition=title_addition, description=description, is_home=true) }} + {{- macros_seo::seo(config=config, title=title, title_addition=title_addition, description=description, is_home=true) }} {%- endblock seo %} @@ -80,12 +80,12 @@ This Template can also be used as the rendering template for Sections, eg: examp {%- else %} {%- set section_item = get_section(path=sec ~ "_index." ~ lang ~ ".md") %} {%- endif %} -
-
-

{%- if lang != config.default_language %}{{ trans(key="Recent_Posts" | safe, lang=lang) }}{% else %}Recent Posts{% endif %}

+
+
+ {%- if lang != config.default_language %}{{ trans(key="Recent_Posts" | safe, lang=lang) }}{% else %}Recent Posts{% endif %} {%- 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) }} + {{- macros::page_listing(page=page, config=config) }} {%- endfor %}
diff --git a/templates/macros/head.html b/templates/macros/head.html deleted file mode 100644 index 3ed3af0..0000000 --- a/templates/macros/head.html +++ /dev/null @@ -1,406 +0,0 @@ -{#- Theme Switcher Button to toggle between dark/light #} -{%- macro theme(config) %} - {%- set integrity = config.extra.integrity | default(value=true) -%} - {%- if config.extra.offline %}{% set integrity = false %}{% endif %} - - {%- if config.extra.js_switcher | default(value=true) %} - {%- 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 %} - - {%- endif %} -{%- endmacro %} - -{%- macro stylesheets(config) %} - {%- set stylesheets=config.extra.stylesheets | default(value=[ "abridge.css" ]) -%} - {%- if stylesheets %}{%- for i in stylesheets %} - - {%- endfor %}{%- endif %} -{%- endmacro %} - - - -{%- macro stylesheets_preload(config) %} - {%- set integrity = config.extra.integrity | default(value=true) -%} - {%- if config.extra.offline %}{% set integrity = false %}{% endif %} - -{%- if config.extra.fonts %}{%- for i in config.extra.fonts %} - {%- if i.url is matching("^http[s]?://") %} - - {%- else %} - - {%- endif %} -{%- endfor %}{%- endif %} - -{%- if config.extra.fontawesome %} - -{%- endif %} - -{%- if config.extra.math or page.extra.math %} - - {%- set katex_css=config.extra.katex_css | default(value="katex.min.css") -%} - {%- if katex_css %}{%- if katex_css is matching("^http[s]?://") %} - - {%- else %} - - {%- endif %}{%- endif %} - -{%- endif %} - -{%- endmacro %} - - - -{%- macro feed(config) %} - {%- if config.generate_feed %} - - {%- endif %} -{%- endmacro %} - - - -{%- macro js(config) %} - {%- set integrity = config.extra.integrity | default(value=true) -%} - {%- if config.extra.offline %}{% set integrity = false %}{% endif %} - {%- set search_library=config.extra.search_library | default(value="elasticlunr") -%} - - {%- set preStyle = false %} - - {%- if config.extra.fonts %}{%- for i in config.extra.fonts %} - {%- if i.url is matching("^http[s]?://") %} - {%- set preStyle = true %} - {%- endif %} - {%- endfor %}{%- endif %} - - {%- if config.extra.fontawesome %} - {%- set preStyle = true %} - {%- endif %} - - {%- if config.extra.math or page.extra.math %} - {%- 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 %} - {%- if config.build_search_index %} - {%- if config.extra.pwa | default(value=false) %} - - {%- else %} - - {%- endif %} - - {%- else %} - {%- if config.extra.pwa | default(value=false) %} - - {%- else %} - - {%- endif %} - {%- endif %} - - {%- if config.build_search_index %} - {%- if search_library == "elasticlunr" %} - {%- if lang != "en" %} - - - {%- endif %} - {%- endif %} - {%- endif %} - -{%- else %}{#- Not js_bundle #} - - {%- if preStyle == true %} - {%- if config.extra.js_prestyle | default(value=true) %} - - {%- endif %} - {%- endif %} - - {%- if config.extra.js_switcher | default(value=true) %} - - {%- endif %} - - {%- if config.extra.js_email_encode | default(value=true) %} - - {%- endif %} - - {%- if config.extra.js_copycode | default(value=true) %} - - {%- endif %} - - {%- if config.extra.pwa | default(value=false) %} - - {%- endif %} - - {%- if search_library == "tinysearch" %} - - {%- elif search_library == "stork" %} - - {%- elif config.build_search_index %} - - {%- 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 %} - - {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} - {%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} - {%- if search_index_format == "elasticlunr_javascript" %}{#- Javascript index format #} - - - - {%- if uglyurls %} - - {%- else %} - - {%- endif %} - - {%- else %} - - {%- endif %} - - {%- if lang != "en" %} - - - {%- endif %} - - {%- endif %} - -{%- endif %} - - -{#- https://katex.org/docs/autorender.html #} -{#- https://github.com/KaTeX/KaTeX/ #} -{#- https://github.com/KaTeX/KaTeX/tree/main/contrib/mathtex-script-type/ #} -{%- if config.extra.math or page.extra.math %} - -{%- set katex_bundle=config.extra.katex_bundle | default(value="js/katexbundle.min.js") -%} -{%- if katex_bundle %} - -{%- else %} - - {%- set katex_js=config.extra.katex_js | default(value="js/katex.min.js") -%} - {%- if katex_js %}{%- if katex_js is matching("^http[s]?://") %} - - {%- else %} - - {%- endif %}{%- endif %} - - {%- 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]?://") %} - - {%- else %} - - {%- endif %}{%- endif %} - - {%- if config.extra.math_auto_render or page.extra.math_auto_render %} - {%- 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]?://") %} - - {%- else %} - - {%- endif %} - {%- endif %} - {%- set katex_options=config.extra.katex_options | default(value="js/katexoptions.js") -%} - {%- if katex_options %} - - {%- endif %} - {%- endif %} -{%- endif %} - -{%- endif %} - -{%- endmacro %} - - - -{%- macro favicons(config) %} - {%- if config.extra.favicon_theme_color %} - - {%- endif %} - - {%- if config.extra.favicon_ms_color %} - - {%- endif %} - - {%- if config.extra.webmanifest %} - - {%- endif %} - - {%- if config.extra.favicon_mask and config.extra.favicon_mask_color %} - - {%- endif %} - - {%- if config.extra.favicon_svg %} - - {%- endif %} - - {%- if config.extra.favicon180 %} - - {%- endif %} - - {%- if config.extra.favicon32 %} - - {%- endif %} - - {%- if config.extra.favicon16 %} - - {%- endif %} -{%- endmacro %} - - - -{%- macro security(config) %} - {%- if config.extra.security_header_referrer %} - - {%- endif %} - {%- if config.extra.security_header_csp %} - - {%- endif %} -{%- endmacro %} - - - -{#- type: website or article, generally setting article for blog articles -#} -{#- 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="2023-05-15T07:07:00-07:00", updated_time="2023-05-15T07:07:00-07:00" ) %} -{%- if is_404 -%} - -{%- else -%} - - - -{%- endif -%} - -{%- if current_url %} - {%- set page_url = current_url %} -{%- else %} - {%- set page_url = get_url(path="404.html", trailing_slash=true) %} -{%- endif %} - {{ title ~ title_addition }} - -{%- if config.extra.author %} - -{%- endif %} -{%- if config.extra.facebook_publisher %} - -{%- endif %} - -{%- if config.extra.facebook_author %} - -{%- endif %} -{%- if page.description %} - -{%- else %} - -{%- endif %} - -{%- if page.extra.keywords and config.extra.keywords %} - -{%- elif page.extra.keywords %} - -{%- elif config.extra.keywords %} - -{%- endif %} - -{#- Extra SEO START #} -{%- if config.extra.seo | default(value=true) %} -{%- if not is_404 %} - -{%- if config.extra.google %} - -{%- endif %} - -{%- if config.extra.bing %} - -{%- endif %} - - - -{%- if page.description %} - - -{%- else %} - - -{%- endif %} - -{%- if page.title %} - - -{%- else %} - - -{%- endif %} - - -{#- SEO MEDIA START #} -{%- if page.extra.thumbnail %} - - - - -{%- elif page.extra.static_thumbnail %} - - {%- if page.extra.static_thumbnail is matching("^http[s]?://") %} - - - {%- else %} - - - {%- endif %} - -{%- elif config.extra.banner %} - - - - -{%- else %} - - -{%- endif %} - -{%- if config.extra.open.audio %} - -{%- endif %} - -{%- if config.extra.open.locale %} - -{%- endif %} - -{%- if config.extra.open.videos %} - {%- for video in config.extra.open.videos %} - - {%- endfor %} -{%- endif %} - -{#- SEO MEDIA END #} - - - -{%- if page.updated %} - -{%- elif page.date %} - -{%- else %} - -{%- endif %} - -{%- if config.extra.twitter_meta %} - - -{%- endif %} - - - -{%- endif %} -{%- endif %} -{#- Extra SEO END #} -{%- endmacro %} diff --git a/templates/macros/macros.html b/templates/macros/macros.html index 000130a..66673d1 100644 --- a/templates/macros/macros.html +++ b/templates/macros/macros.html @@ -1,9 +1,21 @@ +{%- macro page_listing(page, config) %} +{%- set uglyurls = config.extra.uglyurls | default(value=false) -%} +{%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} + +{%- endmacro page_listing %} + + + {%- macro title_post(page, config) %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} {%- if config.extra.offline %}{% set uglyurls = true %}{% endif %}

{{ page.title }}

{%- endmacro title_post %} + + {%- macro meta_post(page, config) %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} {%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} @@ -29,7 +41,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.updated or config.extra.meta_post.categories_tags %} - {%- if config.extra.meta_post.divider %}{{ config.extra.meta_post.divider | safe }}{%- else %}   {%- endif %} + {%- if config.extra.meta_post.divider %}{{ config.extra.meta_post.divider | safe }}{%- else %} {%- endif %} {%- endif %} {%- endif %} @@ -37,7 +49,7 @@ {%- if config.extra.meta_post.readtime %} {%- if config.extra.icon_read %} {% endif %} {{ page.reading_time }} {{ config.extra.meta_post.readstring | default(value="min") }} {#- divider #} {%- 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 %}{{ config.extra.meta_post.divider | safe }}{%- else %}   {%- endif %}{%- endif %}{%- endif %} + {%- if config.extra.meta_post.divider %}{{ config.extra.meta_post.divider | safe }}{%- else %} {%- endif %}{%- endif %}{%- endif %} {#- Date #} {%- if config.extra.meta_post.date %} {%- if config.extra.icon_date %} {% endif %} @@ -51,7 +63,7 @@ {%- 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 %}{{ config.extra.meta_post.divider | safe }}{%- else %}   {%- endif %}{%- endif %}{% endif %} + {%- if config.extra.meta_post.divider %}{{ config.extra.meta_post.divider | safe }}{%- else %} {%- endif %}{%- endif %}{% endif %} {#- Updated #} {%- if config.extra.meta_post.updated and page.updated %} {%- if config.extra.icon_date %} {% endif -%} @@ -65,7 +77,7 @@ {%- else %} {{ page.updated | date(format="%B %d, %Y") }} {%- endif %} {#- divider #} {%- if config.extra.meta_post.categories_tags %} - {%- if config.extra.meta_post.divider %}{{ config.extra.meta_post.divider | safe }}{%- else %}   {%- endif %}{%- endif %}{% endif %} + {%- if config.extra.meta_post.divider %}{{ config.extra.meta_post.divider | safe }}{%- else %} {%- endif %}{%- endif %}{% endif %} {#- Categories #} {%- if page.taxonomies.categories %} {%- if config.extra.icon_info %} {% endif %} [{% for cat in page.taxonomies.categories %}{{ cat }}{% endfor %}]{% endif %} @@ -74,6 +86,8 @@ {%- if page.taxonomies.tags %} {%- for tag in page.taxonomies.tags %} #{{ tag }} {% endfor -%}{%- endif %} {%- endmacro meta_post %} + + {%- macro title_index(page, config) %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} {%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} @@ -81,6 +95,7 @@ {%- endmacro title_index %} + {%- macro meta_index(page, config) %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} {%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} @@ -106,7 +121,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.updated or config.extra.meta_index.categories_tags %} - {%- if config.extra.meta_index.divider %}{{ config.extra.meta_index.divider | safe }}{%- else %}   {%- endif %} + {%- if config.extra.meta_index.divider %}{{ config.extra.meta_index.divider | safe }}{%- else %} {%- endif %} {%- endif %} {%- endif %} @@ -114,7 +129,7 @@ {%- if config.extra.meta_index.readtime %} {%- if config.extra.icon_read %} {% endif %} {{ page.reading_time }} {{ config.extra.meta_index.readstring | default(value="min") }} {#- divider #} {%- 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 %}{{ config.extra.meta_index.divider | safe }}{%- else %}   {%- endif %}{%- endif %}{%- endif %} + {%- if config.extra.meta_index.divider %}{{ config.extra.meta_index.divider | safe }}{%- else %} {%- endif %}{%- endif %}{%- endif %} {#- Date #} {%- if config.extra.meta_index.date %} {%- if config.extra.icon_date %} {% endif %} @@ -128,7 +143,7 @@ {%- 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 %}{{ config.extra.meta_index.divider | safe }}{%- else %}   {%- endif %}{%- endif %}{% endif %} + {%- if config.extra.meta_index.divider %}{{ config.extra.meta_index.divider | safe }}{%- else %} {%- endif %}{%- endif %}{% endif %} {#- Updated #} {%- if config.extra.meta_index.updated and page.updated %} {%- if config.extra.icon_date %} {% endif -%} @@ -143,7 +158,7 @@ {#- divider #} {%- if config.extra.meta_index.categories_tags %} - {%- if config.extra.meta_index.divider %}{{ config.extra.meta_index.divider | safe }}{%- else %}   {%- endif %}{%- endif %}{% endif %} + {%- if config.extra.meta_index.divider %}{{ config.extra.meta_index.divider | safe }}{%- else %} {%- endif %}{%- endif %}{% endif %} {#- Categories #} {%- if page.taxonomies.categories %} {%- if config.extra.icon_info %} {% endif %} [{% for cat in page.taxonomies.categories %}{{ cat }}{% endfor %}]{% endif %} @@ -154,7 +169,6 @@ - {%- macro footer(page, config) %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} {%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} @@ -178,6 +192,7 @@ {%- endmacro footer %} + {%- macro pagination(paginator, config)%} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} {%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} diff --git a/templates/macros/page.html b/templates/macros/page.html deleted file mode 100644 index 23b9e09..0000000 --- a/templates/macros/page.html +++ /dev/null @@ -1,7 +0,0 @@ -{%- macro page_listing(page, config) %} -{%- set uglyurls = config.extra.uglyurls | default(value=false) -%} -{%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} - -{%- endmacro page_listing %} diff --git a/templates/macros/seo.html b/templates/macros/seo.html new file mode 100644 index 0000000..8d2ada1 --- /dev/null +++ b/templates/macros/seo.html @@ -0,0 +1,140 @@ +{#- type: website or article, generally setting article for blog articles -#} +{#- 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="2023-05-15T07:07:00-07:00", updated_time="2023-05-15T07:07:00-07:00" ) %} + +{%- if is_404 -%} + +{%- else -%} + + + +{%- endif -%} + +{%- if current_url %} + {%- set page_url = current_url %} +{%- else %} + {%- set page_url = get_url(path="404.html", trailing_slash=true) %} +{%- endif %} + {{ title ~ title_addition }} + +{%- if config.extra.author %} + +{%- endif %} +{%- if config.extra.facebook_publisher %} + +{%- endif %} + +{%- if config.extra.facebook_author %} + +{%- endif %} +{%- if page.description %} + +{%- else %} + +{%- endif %} + +{%- if page.extra.keywords and config.extra.keywords %} + +{%- elif page.extra.keywords %} + +{%- elif config.extra.keywords %} + +{%- endif %} + +{#- Extra SEO START #} +{%- if config.extra.seo | default(value=true) %} +{%- if not is_404 %} + +{%- if config.extra.google %} + +{%- endif %} + +{%- if config.extra.bing %} + +{%- endif %} + + + +{%- if page.description %} + + +{%- else %} + + +{%- endif %} + +{%- if page.title %} + + +{%- else %} + + +{%- endif %} + + +{#- SEO MEDIA START #} +{%- if page.extra.thumbnail %} + + + + +{%- elif page.extra.static_thumbnail %} + + {%- if page.extra.static_thumbnail is matching("^http[s]?://") %} + + + {%- else %} + + + {%- endif %} + +{%- elif config.extra.banner %} + + + + +{%- else %} + + +{%- endif %} + +{%- if config.extra.open.audio %} + +{%- endif %} + +{%- if config.extra.open.locale %} + +{%- endif %} + +{%- if config.extra.open.videos %} + {%- for video in config.extra.open.videos %} + + {%- endfor %} +{%- endif %} + +{#- SEO MEDIA END #} + + + +{%- if page.updated %} + +{%- elif page.date %} + +{%- else %} + +{%- endif %} + +{%- if config.extra.twitter_meta %} + + +{%- endif %} + + + +{%- endif %} +{%- endif %} +{#- Extra SEO END #} +{%- endmacro %} diff --git a/templates/macros/social.html b/templates/macros/social.html deleted file mode 100644 index 8661976..0000000 --- a/templates/macros/social.html +++ /dev/null @@ -1,58 +0,0 @@ -{%- macro social_links(config) %} - -{%- endmacro %} diff --git a/templates/page.html b/templates/page.html index 253b0d9..198e190 100644 --- a/templates/page.html +++ b/templates/page.html @@ -1,4 +1,4 @@ -{# This Page Shows the Individual Blog Posts#} +{# This Template Shows the Individual Blog Posts#} {% extends "base.html" %} @@ -27,7 +27,7 @@ {%- set page_section = "" %} {%- endif %} - {{- 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) }} + {{- macros_seo::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 %} @@ -45,33 +45,35 @@ {{- macros::meta_post(page=page, config=config) }} {%- endif %}{%- endif %} - + {# In Page Series Navigation #} + {%- if config.extra.series | default(value=true) %} {%- if page.extra.section %} - + {%- set tag = get_taxonomy_term(kind="tags", term=page.extra.section, lang=lang) %} {%- set page_num = tag.page_count | as_str %} {%- if lang != config.default_language %} {%- set parts_string = trans(key="Series_parts", lang=lang) | replace(from="$NUMBER_OF_PARTS", to=page_num) %} {% else %} - {%- set parts_string = page_num ~ " part Series" %} + {%- set parts_string = config.extra.Series_parts | default(value="Series") | replace(from="$NUMBER_OF_PARTS", to=page_num) %} {% endif -%} - - -
- {{ tag.name }} ({{ parts_string }}) -
    - {%- for inner in tag.pages | sort(attribute="year") %} - {%- if inner.content == page.content %} -
  1. {{ inner.title }}
  2. - {% else %} -
  3. {{ inner.title }}
  4. - {%- endif %} - {%- endfor %} -
+
+
+ {{ tag.name }} ({{ parts_string }}) +
    + {%- for inner in tag.pages | sort(attribute="year") %} + {%- if inner.content == page.content %} +
  1. {{ inner.title }}
  2. + {% else %} +
  3. {{ inner.title }}
  4. + {%- endif %} + {%- endfor %} +
+
{%- endif %} + {%- endif %} {{ page.content | safe }} @@ -92,15 +94,16 @@ {%- endblock comments_body %} {%- block toc %} - {%- if page.extra.toc and config.extra.recent %} + {%- if config.extra.toc | default(value=true) %} + {%- if page.extra.toc %} {%- set toc = page.toc %} {%- endif %} {%- if toc %} - -
+ +
{%- if page.extra.section %} -
- {{ parts_string }} +
+ {{ parts_string }}
    {%- for inner in tag.pages | sort(attribute="year") %} {%- if inner.content == page.content %} @@ -113,16 +116,16 @@
{%- endif %} -
- {%- if lang != config.default_language %}{{ trans(key="Index" | safe, lang=lang) }}{% else %}Index{% endif %} +
+ {%- if lang != config.default_language %}{{ trans(key="Index" | safe, lang=lang) }}{% else %}Index{% endif %} {%- for h in toc %} -
- {{ h.title }} + {%- if h.children %} {%- for h2 in h.children %} -
- - {{ h2.title }} + {%- endfor %} {%- endif %} @@ -130,6 +133,7 @@
{%- endif %} + {%- endif %} {%- endblock toc %} {%- endblock content %} diff --git a/templates/pages.html b/templates/pages.html index 4ef44f5..72f4071 100644 --- a/templates/pages.html +++ b/templates/pages.html @@ -1,4 +1,8 @@ -{# This Page Shows the 'Pages' (abridge/content/pages) eg: example.com/about/ example.com/privacy/ #} +{# +This Template is for the 'Pages' (abridge/content/pages) eg: example.com/about/ example.com/privacy/ +This Template can also be used as a home page for the index, eg: example.com/ +Some people prefer a landing page for the index, and then use a separate paginated page for their blog. +#} {% extends "base.html" %} @@ -9,24 +13,35 @@ {%- if page.title and config.title %} {%- set title = page.title %} {%- set title_addition = title_separator ~ config.title %} + {%- elif section.title and config.title %} + {%- set title = section.title %} + {%- set title_addition = title_separator ~ config.title %} {%- elif page.title %} {%- set title = page.title %} + {%- elif section.title %} + {%- set title = section.title %} {%- else %} {%- set title = config.title %} {%- endif %} {%- if page.description %} {%- set description = page.description %} + {%- elif section.description %} + {%- set description = section.description %} {%- else %} {%- set description = config.description %} {%- endif %} - {{- macros_head::seo(config=config, title=title, title_addition=title_addition, description=description) }} + {{- macros_seo::seo(config=config, title=title, title_addition=title_addition, description=description) }} {%- endblock seo %} {%- block content %}
+{%- if page.content %} {{ page.content | safe }} +{%- elif section.content %} +{{ section.content | safe }} +{%- endif %}
{%- endblock content %} diff --git a/templates/partials/head.html b/templates/partials/head.html new file mode 100644 index 0000000..4e6b713 --- /dev/null +++ b/templates/partials/head.html @@ -0,0 +1,131 @@ + +{#- Theme Switcher Button to toggle between dark/light #} + {%- set integrity = config.extra.integrity | default(value=true) -%} + {%- if config.extra.offline %}{% set integrity = false %}{% endif %} + + {%- if config.extra.js_switcher | default(value=true) %} + {%- 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 %} + + {%- endif %} + + + + + +{#- Style Sheets #} + {%- set stylesheets=config.extra.stylesheets | default(value=[ "abridge.css" ]) -%} + {%- if stylesheets %}{%- for i in stylesheets %} + + {%- endfor %}{%- endif %} + + + + + +{#- meta tags #} + + + + + + + + + + + + + +{#- Security: CSP, referrer #} + {%- if config.extra.security_header_referrer %} + + {%- endif %} + {%- if config.extra.security_header_csp %} + + {%- endif %} + + + + + +{#- Favicons #} + {%- if config.extra.favicon_theme_color %} + + {%- endif %} + + {%- if config.extra.favicon_ms_color %} + + {%- endif %} + + {%- if config.extra.webmanifest %} + + {%- endif %} + + {%- if config.extra.favicon_mask and config.extra.favicon_mask_color %} + + {%- endif %} + + {%- if config.extra.favicon_svg %} + + {%- endif %} + + {%- if config.extra.favicon180 %} + + {%- endif %} + + {%- if config.extra.favicon32 %} + + {%- endif %} + + {%- if config.extra.favicon16 %} + + {%- endif %} + + + + + +{#- Style Sheets Preload #} + {%- set integrity = config.extra.integrity | default(value=true) -%} + {%- if config.extra.offline %}{% set integrity = false %}{% endif %} + +{%- if config.extra.fonts %}{%- for i in config.extra.fonts %} + {%- if i.url is matching("^http[s]?://") %} + + {%- else %} + + {%- endif %} +{%- endfor %}{%- endif %} + +{%- if config.extra.fontawesome %} + +{%- endif %} + +{%- if config.extra.math or page.extra.math %} + + {%- set katex_css=config.extra.katex_css | default(value="katex.min.css") -%} + {%- if katex_css %}{%- if katex_css is matching("^http[s]?://") %} + + {%- else %} + + {%- endif %}{%- endif %} + +{%- endif %} + + + + + +{#- Rss / Atom Feed #} + {%- if config.generate_feed %} + + {%- endif %} + + + + + +{#- End of head partial -#} diff --git a/templates/partials/head_js.html b/templates/partials/head_js.html new file mode 100644 index 0000000..9a5604a --- /dev/null +++ b/templates/partials/head_js.html @@ -0,0 +1,165 @@ +{#- JAVASCRIPT #} + {%- set integrity = config.extra.integrity | default(value=true) -%} + {%- if config.extra.offline %}{% set integrity = false %}{% endif %} + {%- set search_library=config.extra.search_library | default(value="elasticlunr") -%} + + {%- set preStyle = false %} + + {%- if config.extra.fonts %}{%- for i in config.extra.fonts %} + {%- if i.url is matching("^http[s]?://") %} + {%- set preStyle = true %} + {%- endif %} + {%- endfor %}{%- endif %} + + {%- if config.extra.fontawesome %} + {%- set preStyle = true %} + {%- endif %} + + {%- if config.extra.math or page.extra.math %} + {%- 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 %} + {%- if config.build_search_index %} + {%- if config.extra.pwa | default(value=false) %} + + {%- else %} + + {%- endif %} + + {%- else %} + {%- if config.extra.pwa | default(value=false) %} + + {%- else %} + + {%- endif %} + {%- endif %} + + {%- if config.build_search_index %} + {%- if search_library == "elasticlunr" %} + {%- if lang != "en" %} + + + {%- endif %} + {%- endif %} + {%- endif %} + +{%- else %}{#- Not js_bundle #} + + {%- if preStyle == true %} + {%- if config.extra.js_prestyle | default(value=true) %} + + {%- endif %} + {%- endif %} + + {%- if config.extra.js_switcher | default(value=true) %} + + {%- endif %} + + {%- if config.extra.js_email_encode | default(value=true) %} + + {%- endif %} + + {%- if config.extra.js_copycode | default(value=true) %} + + {%- endif %} + + {%- if config.extra.pwa | default(value=false) %} + + {%- endif %} + + {%- if search_library == "tinysearch" %} + + {%- elif search_library == "stork" %} + + {%- elif config.build_search_index %} + + {%- 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 %} + + {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} + {%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} + {%- if search_index_format == "elasticlunr_javascript" %}{#- Javascript index format #} + + + + {%- if uglyurls %} + + {%- else %} + + {%- endif %} + + {%- else %} + + {%- endif %} + + {%- if lang != "en" %} + + + {%- endif %} + + {%- endif %} + +{%- endif %} + + + + + +{#- Katex #} +{#- https://katex.org/docs/autorender.html #} +{#- https://github.com/KaTeX/KaTeX/ #} +{#- https://github.com/KaTeX/KaTeX/tree/main/contrib/mathtex-script-type/ #} +{%- if config.extra.math or page.extra.math %} + +{%- set katex_bundle=config.extra.katex_bundle | default(value="js/katexbundle.min.js") -%} +{%- if katex_bundle %} + +{%- else %} + + {%- set katex_js=config.extra.katex_js | default(value="js/katex.min.js") -%} + {%- if katex_js %}{%- if katex_js is matching("^http[s]?://") %} + + {%- else %} + + {%- endif %}{%- endif %} + + {%- 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]?://") %} + + {%- else %} + + {%- endif %}{%- endif %} + + {%- if config.extra.math_auto_render or page.extra.math_auto_render %} + {%- 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]?://") %} + + {%- else %} + + {%- endif %} + {%- endif %} + {%- set katex_options=config.extra.katex_options | default(value="js/katexoptions.js") -%} + {%- if katex_options %} + + {%- endif %} + {%- endif %} +{%- endif %} + +{%- endif %} + + + + + + +{#- End of head_js partial -#} diff --git a/templates/partials/social.html b/templates/partials/social.html new file mode 100644 index 0000000..aaca83d --- /dev/null +++ b/templates/partials/social.html @@ -0,0 +1,63 @@ +{#- Social Footer Icons #} + + + + + + +{#- End of social partial -#} diff --git a/templates/shortcodes/img.html b/templates/shortcodes/img.html index f5754ce..ac3ba6b 100644 --- a/templates/shortcodes/img.html +++ b/templates/shortcodes/img.html @@ -1,15 +1,16 @@ {%- set img = src | split(pat="/") | last %} {%- set dirtest = src | trim_start_matches(pat="./") %} {%- if dirtest is containing("/") %} {%- set reldir = true %} {%- endif %} +{%- if page.path %}{%- set pagepath = page.path %}{%- elif section.path %}{%- set pagepath = section.path %}{%- endif %} {%- if src is starting_with("./") and reldir %} {# Relative Path #} {%- set path = src | trim_start_matches(pat="./") | split(pat="/") | slice(end=-1) | join(sep="/") | trim_start_matches(pat="/") %} {%- set path = path ~ "/" %} {%- if not w or not h %} {%- if lang != config.default_language %} - {%- set metapath = page.path ~ path ~ img | replace(from=page.path | truncate(length=4, end=""), to="/") %} + {%- set metapath = pagepath ~ path ~ img | replace(from=pagepath | truncate(length=4, end=""), to="/") %} {%- else %} - {%- set metapath = page.path ~ path ~ img %} + {%- set metapath = pagepath ~ path ~ img %} {%- endif %} {%- set meta = get_image_metadata(path=metapath) %} {%- set w = meta.width %} @@ -30,9 +31,9 @@ {%- set path = "" %} {%- if not w or not h %} {%- if lang != config.default_language %} - {%- set metapath = page.path ~ img | replace(from=page.path | truncate(length=4, end=""), to="/") %} + {%- set metapath = pagepath ~ img | replace(from=pagepath | truncate(length=4, end=""), to="/") %} {%- else %} - {%- set metapath = page.path ~ img %} + {%- set metapath = pagepath ~ img %} {%- endif %} {%- set meta = get_image_metadata(path=metapath) %} {%- set w = meta.width %} diff --git a/templates/shortcodes/imgswap.html b/templates/shortcodes/imgswap.html index efcf6e7..80a3b74 100644 --- a/templates/shortcodes/imgswap.html +++ b/templates/shortcodes/imgswap.html @@ -2,15 +2,16 @@ {%- set img = main_src | split(pat="/") | last %} {%- set dirtest = main_src | trim_start_matches(pat="./") %} {%- if dirtest is containing("/") %} {%- set reldir = true %} {%- endif %} + {%- if page.path %}{%- set pagepath = page.path %}{%- elif section.path %}{%- set pagepath = section.path %}{%- endif %} {%- if main_src is starting_with("./") and reldir %} {# Relative Path #} {%- set path = main_src | trim_start_matches(pat="./") | split(pat="/") | slice(end=-1) | join(sep="/") | trim_start_matches(pat="/") %} {%- set path = path ~ "/" %} {%- if not w or not h %} {%- if lang != config.default_language %} - {%- set metapath = page.path ~ path ~ img | replace(from=page.path | truncate(length=4, end=""), to="/") %} + {%- set metapath = pagepath ~ path ~ img | replace(from=pagepath | truncate(length=4, end=""), to="/") %} {%- else %} - {%- set metapath = page.path ~ path ~ img %} + {%- set metapath = pagepath ~ path ~ img %} {%- endif %} {%- set meta = get_image_metadata(path=metapath) %} {%- set w = meta.width %} @@ -31,9 +32,9 @@ {%- set path = "" %} {%- if not w or not h %} {%- if lang != config.default_language %} - {%- set metapath = page.path ~ img | replace(from=page.path | truncate(length=4, end=""), to="/") %} + {%- set metapath = pagepath ~ img | replace(from=pagepath | truncate(length=4, end=""), to="/") %} {%- else %} - {%- set metapath = page.path ~ img %} + {%- set metapath = pagepath ~ img %} {%- endif %} {%- set meta = get_image_metadata(path=metapath) %} {%- set w = meta.width %} @@ -55,9 +56,9 @@ {%- set path = path ~ "/" %} {%- if not w or not h %} {%- if lang != config.default_language %} - {%- set metapath = page.path ~ path ~ img | replace(from=page.path | truncate(length=4, end=""), to="/") %} + {%- set metapath = pagepath ~ path ~ img | replace(from=pagepath | truncate(length=4, end=""), to="/") %} {%- else %} - {%- set metapath = page.path ~ path ~ img %} + {%- set metapath = pagepath ~ path ~ img %} {%- endif %} {%- set meta = get_image_metadata(path=metapath) %} {%- set w = meta.width %} @@ -78,9 +79,9 @@ {%- set path = "" %} {%- if not w or not h %} {%- if lang != config.default_language %} - {%- set metapath = page.path ~ img | replace(from=page.path | truncate(length=4, end=""), to="/") %} + {%- set metapath = pagepath ~ img | replace(from=pagepath | truncate(length=4, end=""), to="/") %} {%- else %} - {%- set metapath = page.path ~ img %} + {%- set metapath = pagepath ~ img %} {%- endif %} {%- set meta = get_image_metadata(path=metapath) %} {%- set w = meta.width %} diff --git a/templates/shortcodes/showdata.html b/templates/shortcodes/showdata.html index 9c14444..7f3d3bc 100644 --- a/templates/shortcodes/showdata.html +++ b/templates/shortcodes/showdata.html @@ -1,3 +1,5 @@ +{# showdata(src="../theme.toml" type="toml" key="min_version") #} + {%- if src and key and type %} {%- if src is matching("^http[s]?://") %} {% set data = load_data(url=src, format=type) %} @@ -5,4 +7,12 @@ {% set data = load_data(path=src, format=type) %} {%- endif %} {{ data[key] }} +{%- else %} + {# Load other file types as plain text #} + {%- if src is matching("^http[s]?://") %} + {% set data = load_data(url=src) %} + {%- else %} + {% set data = load_data(path=src) %} + {%- endif %} + {{ data }} {%- endif %} diff --git a/templates/tags/list.html b/templates/tags/list.html index 2124b02..4f53a58 100644 --- a/templates/tags/list.html +++ b/templates/tags/list.html @@ -14,7 +14,7 @@ {%- set description = config.description %} - {{- macros_head::seo(config=config, title=title, title_addition=title_addition, description=description, is_home=true) }} + {{- macros_seo::seo(config=config, title=title, title_addition=title_addition, description=description, is_home=true) }} {%- endblock seo %} {%- block content %} diff --git a/templates/tags/single.html b/templates/tags/single.html index d21d9b0..a57b1f7 100644 --- a/templates/tags/single.html +++ b/templates/tags/single.html @@ -14,7 +14,7 @@ {%- set description = config.description %} - {{- macros_head::seo(config=config, title=title, title_addition=title_addition, description=description, is_home=true) }} + {{- macros_seo::seo(config=config, title=title, title_addition=title_addition, description=description, is_home=true) }} {%- endblock seo %} {%- block content %} -- cgit v1.3.1