{#- JAVASCRIPT -#}
{%- set integrity = (config.extra.integrity if config.extra.integrity is defined else true) -%}
{%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{%- set integrity = false -%}{%- endif -%}{%- endif -%}
{%- set search_library=(config.extra.search_library if config.extra.search_library else "elasticlunr") -%}
{%- set preStyle = false -%}
{%- if config.extra.fonts -%}{%- for i in config.extra.fonts -%}
{%- if i.url is matching(pat="^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 if config.extra.katex_css else "katex.min.css") -%}
{%- if katex_css -%}
{%- set preStyle = true -%}
{%- endif -%}
{%- endif -%}
{%- if config.mode != "serve" -%}{%- set notserve = true -%}{%- endif -%}
{%- if config.extra.js_bundle -%}
{%- if config.build_search_index -%}
{%- if notserve and (config.extra.pwa or false) %}
{%- else %}
{%- endif -%}
{%- else %}
{%- if notserve and (config.extra.pwa or 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 if config.extra.js_prestyle is defined else true) %}
{%- endif %}
{%- endif %}
{%- if (config.extra.js_switcher if config.extra.js_switcher is defined else true) %}
{%- endif %}
{%- if (config.extra.js_email_encode if config.extra.js_email_encode is defined else true) %}
{%- endif %}
{%- if (config.extra.js_copycode if config.extra.js_copycode is defined else true) %}
{%- endif %}
{%- if notserve and (config.extra.pwa or false) %}
{%- endif %}
{%- if search_library == "tinysearch" %}
{%- 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 or false) -%}
{%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set uglyurls = true %}{% endif %}{% 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 if config.extra.katex_bundle else "js/katexbundle.min.js") -%}
{%- if katex_bundle %}
{%- else %}
{%- set katex_js=(config.extra.katex_js if config.extra.katex_js else "js/katex.min.js") -%}
{%- if katex_js %}{%- if katex_js is matching(pat="^http[s]?://") %}
{%- else %}
{%- endif %}{%- endif %}
{%- set mathtex_js=(config.extra.mathtex_js if config.extra.mathtex_js else "js/mathtex-script-type.min.js") -%}
{%- if mathtex_js %}{%- if mathtex_js is matching(pat="^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 if config.extra.katex_autorender_js else "js/katex-auto-render.min.js") -%}
{%- if katex_autorender_js %}
{%- if katex_autorender_js is matching(pat="^http[s]?://") %}
{%- else %}
{%- endif %}
{%- endif %}
{%- set katex_options=(config.extra.katex_options if config.extra.katex_options else "js/katexoptions.js") -%}
{%- if katex_options %}
{%- endif %}
{%- endif %}
{%- endif %}
{%- endif %}
{#- End of head_js partial #}