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/macros/head.html | 406 ------------------------------------------- templates/macros/macros.html | 33 +++- templates/macros/page.html | 7 - templates/macros/seo.html | 140 +++++++++++++++ templates/macros/social.html | 58 ------- 5 files changed, 164 insertions(+), 480 deletions(-) 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 (limited to 'templates/macros') 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 %} +
+ {{ page.title }} +
+{%- 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 %} -
- {{ page.title }} -
-{%- 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 %} -- cgit v1.3.1