From 5e55301cc2c91a5f0e99000bfe4d7ec262ee78c1 Mon Sep 17 00:00:00 2001 From: Jieiku Date: Fri, 8 Sep 2023 15:08:39 -0700 Subject: Refactor package.json --- templates/macros/head.html | 87 ++++++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 37 deletions(-) (limited to 'templates/macros/head.html') diff --git a/templates/macros/head.html b/templates/macros/head.html index fe4eb53..cea56c8 100644 --- a/templates/macros/head.html +++ b/templates/macros/head.html @@ -1,22 +1,17 @@ {#- 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 %} - -{#- Service Worker for PWA #} -{%- macro pwa(config) %} - {%- if config.extra.pwa | default(value=false) %} - + {%- endif %} {%- endmacro %} - {%- macro stylesheets(config) %} {%- set stylesheets=config.extra.stylesheets | default(value=[ "abridge.css" ]) -%} {%- if stylesheets %}{%- for i in stylesheets %} @@ -27,6 +22,8 @@ {%- 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]?://") %} @@ -44,9 +41,9 @@ {%- 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 %} @@ -64,6 +61,8 @@ {%- 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 %} @@ -88,16 +87,25 @@ {%- 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 %} @@ -106,26 +114,30 @@ {%- 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" -%} @@ -135,24 +147,25 @@ {%- endif %} {%- endif %} - {%- set uglyurls=config.extra.uglyurls | default(value=false) -%} + {%- 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 %} @@ -167,35 +180,35 @@ {%- 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 %} -- cgit v1.3.1