From ca22b6115b45931187ecc5e3001eb252ade169f3 Mon Sep 17 00:00:00 2001
From: Jieiku
Date: Thu, 9 Jun 2022 21:57:10 -0700
Subject: Add Theme Switcher
---
templates/macros/head.html | 208 ++++++++++++++++++++++++++++++++-------------
1 file changed, 150 insertions(+), 58 deletions(-)
(limited to 'templates/macros/head.html')
diff --git a/templates/macros/head.html b/templates/macros/head.html
index 4dc5895..2df6fef 100644
--- a/templates/macros/head.html
+++ b/templates/macros/head.html
@@ -1,37 +1,164 @@
-{%- macro stylesheet() %}
-
+{%- macro theme() %}
+ {%- if config.extra.js_theme %}
+ {%- if config.extra.js_themeButton or config.extra.js_bundle %}
+
+ {%- endif %}
+ {%- endif %}
{%- endmacro %}
+{%- macro stylesheets() %}
+
+ {%- if config.extra.stylesheets %}{%- for i in config.extra.stylesheets %}
+
+ {%- endfor %}{%- endif %}
-{%- macro resource() %}
{%- 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.build_search_index %}
+{%- if config.extra.math or page.extra.math %}
+
+ {%- if config.extra.katex_css %}{%- if config.extra.katex_css is matching("^http[s]?://") %}
+
+ {%- else %}
+
+ {%- endif %}{%- endif %}
+
+{%- endif %}
+
+{%- endmacro %}
+
+
+
+{%- macro feed() %}
+ {%- if config.generate_feed %}
+
+ {%- endif %}
+{%- endmacro %}
+
+
+
+{%- macro js() %}
+
+ {%- 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 %}
+ {%- if config.extra.katex_css %}
+ {%- set preStyle = true %}
+ {%- endif %}
+ {%- endif %}
+
+{%- if config.build_search_index and config.extra.js_bundle %}
+
{%- if config.extra.js_search_index %}
{%- endif %}
- {%- if config.extra.js_search %}
-
+
+ {%- if config.extra.js_bundle %}
+
{%- endif %}
+
+{%- elif config.build_search_index %}
+
+ {#- no bundle #}
+
+ {%- if preStyle == true %}
+ {%- if config.extra.js_prestyle %}
+
+ {%- endif %}
+ {%- endif %}
+
+ {%- if config.extra.js_theme %}
+ {%- if config.extra.js_themeButton %}
+
+ {%- endif %}
+ {%- endif %}
+
+ {%- if config.extra.js_search_index %}
+
+ {%- endif %}
+ {%- if config.extra.js_search %}{%- for i in config.extra.js_search %}
+
+ {%- endfor %}{%- endif %}
+
+{%- elif config.extra.js_bundle %}
+
+ {#- no search #}
+
+
+
+{%- 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 %}
+
+
+{%- 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 %}
+
+ {%- if config.extra.katex_js %}{%- if config.extra.katex_js is matching("^http[s]?://") %}
+
+ {%- else %}
+
+ {%- endif %}{%- endif %}
+
+ {%- if config.extra.mathtex_js %}{%- if config.extra.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]?://") %}
+
+ {%- else %}
+
+ {%- endif %}
+ {%- endif %}
+
{%- endif %}
-{%- if config.generate_feed %}
-
{%- endif %}
{%- endmacro %}
+
{%- macro favicons() %}
{%- if config.extra.favicon_theme_color %}
@@ -63,6 +190,18 @@
{%- endmacro %}
+
+{%- macro security() %}
+ {%- 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 -#}
@@ -199,50 +338,3 @@
{%- endif %}
{#- Extra SEO END #}
{%- endmacro %}
-
-{%- macro security() %}
- {%- if config.extra.security_header_referrer %}
-
- {%- endif %}
- {%- if config.extra.security_header_csp %}
-
- {%- endif %}
-{%- endmacro %}
-
-{# https://katex.org/docs/autorender.html #}
-{# https://github.com/KaTeX/KaTeX/ #}
-{# https://github.com/KaTeX/KaTeX/tree/main/contrib/mathtex-script-type/ #}
-{%- macro math() %}
-{%- if config.extra.math or page.extra.math %}
-
- {%- if config.extra.katex_css %}{%- if config.extra.katex_css is matching("^http[s]?://") %}
-
- {%- else %}
-
- {%- endif %}{%- endif %}
-
- {%- if config.extra.katex_js %}{%- if config.extra.katex_js is matching("^http[s]?://") %}
-
- {%- else %}
-
- {%- endif %}{%- endif %}
-
- {%- if config.extra.mathtex_js %}{%- if config.extra.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]?://") %}
-
- {%- else %}
-
- {%- endif %}
- {%- endif %}
-
-{%- endif %}
-
-{%- endif %}
-{%- endmacro %}
--
cgit v1.3.1