From 940b40688a7cf595eee061b696187e2fe4a578e2 Mon Sep 17 00:00:00 2001 From: Jieiku Date: Mon, 22 May 2023 22:31:34 -0700 Subject: Json-Index and config.toml optional --- templates/macros/head.html | 240 +++++++++++++++++++------------------------ templates/macros/macros.html | 20 ++-- templates/macros/social.html | 2 +- 3 files changed, 120 insertions(+), 142 deletions(-) (limited to 'templates/macros') diff --git a/templates/macros/head.html b/templates/macros/head.html index 528577a..3767a16 100644 --- a/templates/macros/head.html +++ b/templates/macros/head.html @@ -1,20 +1,24 @@ {#- 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 %} - + {%- if config.extra.js_switcher | default(value=true) %} + {%- set js_theme=config.extra.js_theme | default(value="theme.min.js") -%} + {%- if js_theme %} + {%- 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 %} {%- endfor %}{%- endif %} - {%- endmacro %} + + {%- macro stylesheets_preload(config) %} {%- if config.extra.fonts %}{%- for i in config.extra.fonts %} @@ -31,10 +35,11 @@ {%- if config.extra.math or page.extra.math %} - {%- if config.extra.katex_css %}{%- if config.extra.katex_css is matching("^http[s]?://") %} - + {%- 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 %} @@ -51,7 +56,21 @@ + + + + + + + + + + + + + {%- macro js(config) %} + {%- set search_library=config.extra.search_library | default(value="elasticlunr") -%} {%- set preStyle = false %} @@ -66,141 +85,60 @@ {%- 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 %} - - {%- endif %} - - {%- if not config.extra.js_search_facade %} +{%- if config.extra.js_bundle %} + - {%- if config.extra.js_switcher %} - - {%- else %} - - {%- endif %} - - {%- elif config.extra.search_library == "tinysearch" %} - - {%- elif config.extra.search_library == "stork" %} - - {%- else %} - - {%- if config.extra.js_switcher %} - - {%- else %} - - {%- endif %} - - {%- endif %} - - -{%- elif config.build_search_index or config.extra.search_library %} - - {#- no bundle #} +{%- else %} {%- if preStyle == true %} - {%- if config.extra.js_prestyle %} - + {%- set js_prestyle=config.extra.js_prestyle | default(value="prestyle.js") -%} + {%- if js_prestyle %} + {%- endif %} {%- endif %} - {%- if config.extra.js_theme %} - {%- if config.extra.js_themeButton %} - + {%- if config.extra.js_switcher | default(value=true) %} + {%- set js_theme=config.extra.js_theme | default(value="theme.min.js") -%} + {%- if js_theme %} + {%- set js_themeButton=config.extra.js_themeButton | default(value="theme_button.js") -%} + {%- if js_themeButton %} + {%- endif %} {%- endif %} - - {%- if config.extra.js_email %} - {%- if config.extra.social.mail_encode %} - - {%- endif %} - {%- endif %} - - {%- if config.extra.js_codecopy %} - {%- endif %} - {%- if config.extra.js_search_facade %} - {%- if config.extra.search_library %} - {%- if config.extra.search_library == "tinysearch" %} - - {%- elif config.extra.search_library == "stork" %} - + {%- set js_email=config.extra.js_email | default(value="email.js") -%} + {%- if js_email %} + {%- if config.extra.social.mail_encode | default(value=true) %} + {%- endif %} {%- endif %} - - {%- endif %} - {%- if config.extra.js_search_facade or config.extra.search_library %} - {#- dont load the index/search #} - {%- elif config.extra.js_search_index %} - + {%- set js_codecopy=config.extra.js_codecopy | default(value="codecopy.js") -%} + {%- if js_codecopy %} + {%- endif %} - {%- if config.extra.js_search_facade %} - {#- dont load the index/search #} - {%- else %} - {%- if config.extra.search_library == "tinysearch" %} - - {%- elif config.extra.search_library == "stork" %} - + {%- if search_library == "tinysearch" %} + + {%- elif search_library == "stork" %} + {%- else %} - - - {%- endif %} + + {%- endif %} -{%- elif config.extra.js_bundle %} - - {#- no search #} - - {%- if config.extra.js_switcher %} - - - {%- else %} - - - {%- endif %} - -{%- else %} - - {#- no bundle or search #} - - {%- if preStyle == true %} - {%- if config.extra.js_prestyle %} - - {%- endif %} - {%- endif %} - - {%- if config.extra.js_theme %} - {%- if config.extra.js_themeButton or config.extra.js_bundle %} - - {%- endif %} - {%- endif %} - - {%- if config.extra.js_email %} - {%- if config.extra.social.mail_encode %} - - {%- endif %} - {%- endif %} +{%- endif %} - {%- if config.extra.js_codecopy %} - - {%- endif %} -{%- endif %} {#- https://katex.org/docs/autorender.html #} @@ -208,31 +146,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 %} - +{%- set katex_bundle=config.extra.katex_bundle | default(value="katexbundle.min.js") -%} +{%- if katex_bundle %} + {%- else %} - {%- if config.extra.katex_js %}{%- if config.extra.katex_js is matching("^http[s]?://") %} - + {%- set katex_js=config.extra.katex_js | default(value="katex.min.js") -%} + {%- if katex_js %}{%- if katex_js is matching("^http[s]?://") %} + {%- else %} - + {%- endif %}{%- endif %} - {%- if config.extra.mathtex_js %}{%- if config.extra.mathtex_js is matching("^http[s]?://") %} - + {%- set mathtex_js=config.extra.mathtex_js | default(value="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 %} - {%- if config.extra.katex_autorender_js %} - {%- if config.extra.katex_autorender_js is matching("^http[s]?://") %} - + {%- set katex_autorender_js=config.extra.katex_autorender_js | default(value="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="katexoptions.js") -%} + {%- if katex_options %} + {%- endif %} - {%- endif %} {%- endif %} @@ -242,6 +187,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + {%- macro favicons(config) %} {%- if config.extra.favicon_theme_color %} @@ -321,9 +293,11 @@ {%- endif %} -{%- if page.extra.keywords %} +{%- if page.extra.keywords and config.extra.keywords %} -{%- else %} +{%- elif page.extra.keywords %} + +{%- elif config.extra.keywords %} {%- endif %} diff --git a/templates/macros/macros.html b/templates/macros/macros.html index 2c17530..95c922c 100644 --- a/templates/macros/macros.html +++ b/templates/macros/macros.html @@ -142,15 +142,19 @@ {%- endif %}