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/base.html | 19 +++- templates/index.html | 3 +- templates/macros/head.html | 240 +++++++++++++++++++------------------------ templates/macros/macros.html | 20 ++-- templates/macros/social.html | 2 +- templates/page.html | 3 +- 6 files changed, 139 insertions(+), 148 deletions(-) (limited to 'templates') diff --git a/templates/base.html b/templates/base.html index 0177ea1..642239b 100644 --- a/templates/base.html +++ b/templates/base.html @@ -51,20 +51,27 @@
{%- if config.build_search_index %} + {%- set icon_search=config.extra.icon_search | default(value="svgs search") -%}
@@ -91,7 +98,9 @@
{%- endif %}
+ {%- if config.extra.social %} {{- social_macros::social_links(social_config=config.extra.social, config=config) }} + {%- endif %} {#- Copyright START #} {%- set copyright_start_year=config.extra.copyright_start_year | default(value="") %} @@ -99,6 +108,7 @@ {%- set copyright_end_year=config.extra.copyright_end_year | default(value=now() | date(format="%Y")) %} Copyright © {{ copyright_start_year ~ copyright_end_year }} {{ config.title }}

{#- Copyright END #} + {%- if config.extra.menu_footer %} + {%- endif %} {%- if config.extra.footer_credit | default(value=true) %} {%- if config.extra.footer_credit_override %} {{ config.extra.footer_credit_override | safe }} @@ -119,4 +130,4 @@ {%- block gotop %} {%- endblock gotop %} - \ No newline at end of file + diff --git a/templates/index.html b/templates/index.html index 7c8c45a..4702e16 100644 --- a/templates/index.html +++ b/templates/index.html @@ -59,7 +59,8 @@

Recent Posts

- {%- for page in section_item.pages | slice(end=config.extra.recent_items) %} + {%- set recent_items=config.extra.recent_items | default(value=9) -%} + {%- for page in section_item.pages | slice(end=recent_items) %} {{- page_macros::page_listing(page=page, config=config) }} {%- endfor %}
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 %}