From 7055cd292c317c140031d12e02e7e590d1f49420 Mon Sep 17 00:00:00 2001 From: welpo Date: Wed, 13 Nov 2024 18:49:38 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20isso=20comments=20in=20mu?= =?UTF-8?q?ltilingual=20setups?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes variable name collision with Zola's built-in current_path that was breaking Isso comments in multilingual sites. Renames the series-related variable to series_path_components to be more descriptive and avoid the conflict. Fixes #426 --- templates/page.html | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/templates/page.html b/templates/page.html index c2a9b7452..1d9929091 100644 --- a/templates/page.html +++ b/templates/page.html @@ -185,11 +185,11 @@

{#- As a series might be a transparent section in order to mix up its articles with those of the section just above or the root, -#} {#- there is no other way but to compute the potential path of each ancestor section related to the page and look for the first one being a series. -#} {#- Using the `ancestors` field of a section is not possible because transparent sections are not present in this field. -#} - {%- set current_path = [] -%} + {%- set series_path_components = [] -%} {%- set section_paths = [] -%} {%- for path in page.relative_path | split(pat="/") | slice(end=-1) -%} - {%- set_global current_path = current_path | concat(with=path) -%} - {%- set section_path = current_path | concat(with="_index.md") | join(sep="/") -%} + {%- set_global series_path_components = series_path_components | concat(with=path) -%} + {%- set section_path = series_path_components | concat(with="_index.md") | join(sep="/") -%} {%- set_global section_paths = section_paths | concat(with=section_path) -%} {%- endfor -%} {#- The series the page is part of is the closest section flagged as a series, if any -#} @@ -261,22 +261,6 @@

{{ processed_content | replace(from="", to=macros_toc::toc(page=page, header=false, language_strings=language_strings)) | safe }} - {#- Check if comments are enabled, checking that they are not disabled on the specific page -#} - {% set systems = ["giscus", "utterances", "hyvortalk", "isso"] %} - {% set enabled_systems = 0 %} - {% set comment_system = "" %} - - {% for system in systems %} - {% set global_enabled = config.extra[system].enabled_for_all_posts | default(value=false) %} - {% set page_enabled = page.extra[system] | default(value=global_enabled) %} - {% set is_enabled = global_enabled and page_enabled != false or page_enabled == true %} - - {% if is_enabled %} - {% set_global comment_system = system %} - {% set_global enabled_systems = enabled_systems + 1 %} - {% endif %} - {% endfor %} - {% if macros_settings::evaluate_setting_priority(setting="show_previous_next_article_links", page=page, default_global_value=true) == "true" %} {%- if page.lower or page.higher -%} {% set next_label = macros_translate::translate(key="next", default="Next", language_strings=language_strings) %} @@ -325,6 +309,21 @@

{%- endif -%} {#- Comments -#} + {#- Check if comments are enabled, checking that they are not disabled on the specific page -#} + {% set systems = ["giscus", "utterances", "hyvortalk", "isso"] %} + {% set enabled_systems = 0 %} + {% set comment_system = "" %} + + {% for system in systems %} + {% set global_enabled = config.extra[system].enabled_for_all_posts | default(value=false) %} + {% set page_enabled = page.extra[system] | default(value=global_enabled) %} + {% set is_enabled = global_enabled and page_enabled != false or page_enabled == true %} + + {% if is_enabled %} + {% set_global comment_system = system %} + {% set_global enabled_systems = enabled_systems + 1 %} + {% endif %} + {% endfor %} {#- Ensure only one comment system is enabled -#} {% if enabled_systems > 1 %} {{ throw(message="ERROR: Multiple comment systems have been enabled for the same page. Check your config.toml and individual page settings to ensure only one comment system is activated at a time.") }}