From b5751ff524f04b99cab8943c046d77444916e1db Mon Sep 17 00:00:00 2001 From: Salar Rahmanian Date: Sat, 17 Feb 2024 14:12:17 -0800 Subject: [PATCH] update theme and configure search --- config.toml | 17 +++++++++++++++++ flake.lock | 8 ++++---- flake.nix | 2 +- templates/partials/footer.html | 5 +++++ templates/partials/header.html | 28 ++++++++++++++++++++++++++++ 5 files changed, 55 insertions(+), 5 deletions(-) diff --git a/config.toml b/config.toml index 7626d44..bda482f 100644 --- a/config.toml +++ b/config.toml @@ -6,6 +6,7 @@ author = "Salar Rahmanian" generate_feed = true compile_sass = true minify_html = true +build_search_index = true # To translate the entire theme, there must be a file with the same ISO 639-1 # (or IETF BCP 47) Code in the `i18n` folder of your site or the tabi theme @@ -19,6 +20,22 @@ taxonomies = [ {name = "tags", feed = true}, ] +[search] +# Whether to include the title of the page/section in the index. +include_title = true +# Whether to include the description of the page/section in the index. +include_description = true +# Whether to include the path of the page/section in the index. +include_path = true +# Whether to include the rendered content of the page/section in the index. +include_content = true +# At which character to truncate the content to. Useful if you have a lot of pages and the index would +# become too big to load on the site. Defaults to not being set. +# truncate_content_length = 100 +# Wether to produce the search index as a javascript file or as a JSON file. +# Accepted value "elasticlunr_javascript" or "elasticlunr_json". +index_format = "elasticlunr_json" + [markdown] highlight_code = true highlight_theme = "css" diff --git a/flake.lock b/flake.lock index a8a6541..cf55e4b 100644 --- a/flake.lock +++ b/flake.lock @@ -25,17 +25,17 @@ "theme": { "flake": false, "locked": { - "lastModified": 1704495088, - "narHash": "sha256-ZfN0qTw2yO+/zU5hkWlB/lOXSJPdcFfVduYUOoSor3A=", + "lastModified": 1707564545, + "narHash": "sha256-m0XIxf3yKBKJwbSonAPDjw7DPHDi0BgRMhhD3FArWA4=", "owner": "welpo", "repo": "tabi", - "rev": "7fa208a2a5dffbc83dd2b71de1e804c2f2eaad01", + "rev": "7e428c899b1bf595100e1448578f9cfc84ad3355", "type": "github" }, "original": { "owner": "welpo", "repo": "tabi", - "rev": "7fa208a2a5dffbc83dd2b71de1e804c2f2eaad01", + "rev": "7e428c899b1bf595100e1448578f9cfc84ad3355", "type": "github" } } diff --git a/flake.nix b/flake.nix index 2832b3d..09ca219 100644 --- a/flake.nix +++ b/flake.nix @@ -4,7 +4,7 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable"; theme = { - url = "github:welpo/tabi/7fa208a2a5dffbc83dd2b71de1e804c2f2eaad01"; + url = "github:welpo/tabi/7e428c899b1bf595100e1448578f9cfc84ad3355"; flake = false; }; }; diff --git a/templates/partials/footer.html b/templates/partials/footer.html index d058c40..7b0e77c 100644 --- a/templates/partials/footer.html +++ b/templates/partials/footer.html @@ -102,5 +102,10 @@ {%- if email_needs_decoding -%} {%- endif -%} + + {# Modal structure for search #} + {%- if config.build_search_index -%} + {% include "partials/search_modal.html" %} + {%- endif -%} diff --git a/templates/partials/header.html b/templates/partials/header.html index 0c50fa2..48d4d06 100644 --- a/templates/partials/header.html +++ b/templates/partials/header.html @@ -1,6 +1,7 @@ + {# Site title #} {%- include "partials/title.html" -%} @@ -160,6 +161,33 @@ {%- if config.extra.analytics.service -%} {%- include "partials/analytics.html" -%} {%- endif -%} + + {# Search #} + {%- if config.build_search_index -%} + {%- if config.search.index_format -%} + {%- set search_index_format = config.search.index_format -%} + {%- elif config.extra.index_format -%} + {# Necessary to support Zola 0.17.X, as it doesn't have access to config.search.index_format #} + {# See: https://github.com/getzola/zola/issues/2165 #} + {%- set search_index_format = config.extra.index_format -%} + {%- else -%} + {%- set search_index_format = "elasticlunr_json" -%} + {%- endif -%} + + {%- if search_index_format == "elasticlunr_javascript" -%} + + {%- endif -%} + + {# Main search script #} + + + {# Support correct stemming and stop word filtering in non-English search #} + {%- if lang != "en" -%} + + + {%- endif -%} + {%- endif -%} + {%- include "partials/custom_header.html" -%}