feat: add series functionality (#406)

Co-authored-by: welpo <welpo@users.noreply.github.com>
This commit is contained in:
ZzMzaw
2024-11-08 00:01:30 +01:00
committed by GitHub
parent 57a0a8e1a0
commit 0253799f23
52 changed files with 1824 additions and 75 deletions

View File

@@ -5,6 +5,7 @@
{% import "macros/settings.html" as macros_settings %}
{% import "macros/table_of_contents.html" as macros_toc %}
{% import "macros/translate.html" as macros_translate %}
{% import "macros/series_page.html" as macros_series_page %}
{# Load the internationalisation data for the current language from
the .toml files in the user's '/i18n' folder, falling back to the theme's.

View File

@@ -1,40 +1,63 @@
{% macro list_posts(posts, max, language_strings="", section_path="blog") %}
{# `metadata` can be "dates", "indexes" or both (e.g. "dates indexes" or "indexes dates"). #}
{# If both, the order doesn't matter and indexes will always be displayed before dates. #}
{# It would also work with arrays (e.g. ["dates"] or ["indexes"] or even ["indexes","dates"]). #}
{# Nevertheless, arrays cannot be used as a default value for a macro parameter in Tera (see https://github.com/Keats/tera/issues/710). #}
{# `paginator` is only used to compute indexes metadata and can be let empty otherwise. #}
{% macro list_posts(posts, max, metadata="dates", language_strings="", section_path="blog", paginator="") %}
{%- set separator = config.extra.separator | default(value="•") -%}
<div class="bloglist-container">
{% for post in posts %}
{% if loop.index <= max %}
{% if loop.index == max %}
<section class="bloglist-row">
{% elif loop.last %}
<section class="bloglist-row">
{% if loop.index == max or loop.last %}
{% set bottom_divider = false %}
{% else %}
<section class="bloglist-row bottom-divider">
{% set bottom_divider = true %}
{% endif %}
<ul class="bloglist-meta">
{%- set allowed_post_listing_dates = ["date", "updated", "both"] -%}
{%- set post_listing_date = config.extra.post_listing_date | default(value="date") -%}
{%- if post_listing_date not in allowed_post_listing_dates -%}
{{ throw(message="ERROR: Invalid value for config.extra.post_listing_date. Allowed values are 'date', 'updated', or 'both'.") }}
<section class="bloglist-meta {% if bottom_divider -%}bottom-divider{%- endif -%}">
<ul>
{%- if "indexes" in metadata -%}
{%- set post_index = loop.index -%}
{%- set nb_posts = posts | length -%}
{# in case we have a pager, the index has been computed for the current page. #}
{%- if paginator -%}
{%- set nb_posts = paginator.total_pages -%}
{%- set number_of_other_pages = paginator.current_index - 1 -%}
{%- set posts_per_page = paginator.paginate_by -%}
{%- set posts_in_other_pages = number_of_other_pages * posts_per_page -%}
{%- set post_index = posts_in_other_pages + post_index -%}
{%- endif -%}
{%- if macros_settings::evaluate_setting_priority(setting="post_listing_index_reversed", page=section, default_global_value=false) == "true" -%}
{# index starts at 1 instead of 0 #}
{%- set post_index = nb_posts + 1 - post_index -%}
{%- endif -%}
<li class="index-label">{{ post_index }}</li>
{%- endif -%}
{%- set show_date = post.date and post_listing_date == "date" or post.date and post_listing_date == "both" or post.date and post_listing_date == "updated" and not post.updated -%}
{%- set show_updated = post.updated and post_listing_date == "updated" or post.updated and post_listing_date == "both" -%}
{%- if show_date or show_updated -%}
{%- if show_date -%}
<li class="date">{{- macros_format_date::format_date(date=post.date, short=false, language_strings=language_strings) -}}</li>
{%- if "dates" in metadata -%}
{%- set allowed_post_listing_dates = ["date", "updated", "both"] -%}
{%- set post_listing_date = config.extra.post_listing_date | default(value="date") -%}
{%- if post_listing_date not in allowed_post_listing_dates -%}
{{ throw(message="ERROR: Invalid value for config.extra.post_listing_date. Allowed values are 'date', 'updated', or 'both'.") }}
{%- endif -%}
{%- if show_date and show_updated -%}
<li class="mobile-only">{{- separator -}}</li>
{%- endif -%}
{%- if show_updated -%}
{%- set last_updated_str = macros_translate::translate(key="last_updated_on", default="Updated on $DATE", language_strings=language_strings) -%}
{%- set formatted_date = macros_format_date::format_date(date=post.updated, short=true, language_strings=language_strings) -%}
{%- set updated_str = last_updated_str | replace(from="$DATE", to=formatted_date) -%}
<li class="date">{{ updated_str }}</li>
{%- set show_date = post.date and post_listing_date == "date" or post.date and post_listing_date == "both" or post.date and post_listing_date == "updated" and not post.updated -%}
{%- set show_updated = post.updated and post_listing_date == "updated" or post.updated and post_listing_date == "both" -%}
{%- if show_date or show_updated -%}
{%- if show_date -%}
<li class="date">{{- macros_format_date::format_date(date=post.date, short=false, language_strings=language_strings) -}}</li>
{%- endif -%}
{%- if show_date and show_updated -%}
<li class="mobile-only">{{- separator -}}</li>
{%- endif -%}
{%- if show_updated -%}
{%- set last_updated_str = macros_translate::translate(key="last_updated_on", default="Updated on $DATE", language_strings=language_strings) -%}
{%- set formatted_date = macros_format_date::format_date(date=post.updated, short=true, language_strings=language_strings) -%}
{%- set updated_str = last_updated_str | replace(from="$DATE", to=formatted_date) -%}
<li class="date">{{ updated_str }}</li>
{%- endif -%}
{%- endif -%}
{%- endif -%}
@@ -42,7 +65,9 @@
<li class="draft-label">{{ macros_translate::translate(key="draft", default="DRAFT", language_strings=language_strings) }}</li>
{% endif %}
</ul>
<div class="bloglist-content">
</section>
<section class="bloglist-content {% if bottom_divider -%}bottom-divider{%- endif -%}">
<div>
<h2 class="bloglist-title">
<a href="{{ post.permalink }}">{{ post.title }}</a>
</h2>

View File

@@ -0,0 +1,162 @@
{#
Those macros deal with introduction and navigation for series pages.
Using macros have been prefered over partial inclusion or inline code to make sure series_ordered_pages is forced to be used.
A section's pages natural order is invalid in case of reversed pagination which would lead to invalid series' pages order.
To prevent this, pages are ordered correctly in a separate variable which must be used instead of the series section pages.
#}
{#
Computes the introduction of a series's page.
Parameters:
- `page`: The page object being part of the series.
- `series_section`: The series' section the page belongs to.
- `series_ordered_pages`: The series' pages properly ordered (see at the top of this file for an explanation).
- `language_strings`: A dictionary containing the translation strings.
#}
{% macro process_series_template(template_type, page, series_section, series_ordered_pages, language_strings) %}
{%- if "series" in series_section.extra and series_section.extra.series -%}
{# Prepare variables for substitution #}
{%- set series_title = series_section.title -%}
{%- set series_permalink = series_section.permalink -%}
{%- set series_html_link = '<a href="' ~ series_section.permalink ~ '" aria_label="' ~ series_section.title ~ '">' ~ series_section.title ~ '</a>' -%}
{# Build series pages list #}
{%- set series_pages_list = [] -%}
{%- for series_page in series_ordered_pages -%}
{%- if series_page.relative_path == page.relative_path -%}
{%- set series_pages_list_item = '<li>' ~ series_page.title ~ '</li>' -%}
{%- else -%}
{%- set series_pages_list_item = '<li><a href="' ~ series_page.permalink ~ '" aria_label="' ~ series_page.title ~ '">' ~ series_page.title ~ '</a></li>' -%}
{%- endif -%}
{%- set_global series_pages_list = series_pages_list | concat(with=series_pages_list_item) -%}
{%- endfor -%}
{%- set series_pages_list = series_pages_list | join(sep="") -%}
{%- if macros_settings::evaluate_setting_priority(setting="post_listing_index_reversed", page=series_section, default_global_value=false) == "true" -%}
{%- set series_pages_ordered_list = '<ol reversed>' ~ series_pages_list ~ '</ol>' -%}
{%- else -%}
{%- set series_pages_ordered_list = '<ol>' ~ series_pages_list ~ '</ol>' -%}
{%- endif -%}
{%- set series_pages_unordered_list = '<ul>' ~ series_pages_list ~ '</ul>' -%}
{# Get page position and navigation info #}
{%- set series_pages_number = 0 -%}
{%- set series_page_index = 0 -%}
{%- set first_page = series_ordered_pages | first -%}
{%- set is_found = false -%}
{%- for series_page in series_ordered_pages -%}
{%- set_global series_pages_number = series_pages_number + 1 -%}
{%- if series_page.relative_path == page.relative_path -%}
{%- set_global series_page_index = series_pages_number -%}
{%- set_global is_found = true -%}
{%- else -%}
{%- if not is_found -%}
{%- set_global prev_page = series_page -%}
{%- elif not next_page is defined -%}
{%- set_global next_page = series_page -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{# Determine template to use based on available navigation #}
{%- set position = "middle" -%}
{%- if prev_page is defined and not next_page is defined -%}
{%- set_global position = "prev_only" -%}
{%- elif next_page is defined and not prev_page is defined -%}
{%- set_global position = "next_only" -%}
{%- endif -%}
{# Get template from config #}
{%- set templates_key = "series_" ~ template_type ~ "_templates" -%}
{%- set template = "" -%}
{%- if series_section.extra[templates_key] is defined -%}
{%- if series_section.extra[templates_key][position] is defined -%}
{%- set_global template = series_section.extra[templates_key][position] -%}
{%- elif series_section.extra[templates_key].default is defined -%}
{%- set_global template = series_section.extra[templates_key].default -%}
{%- endif -%}
{%- endif -%}
{# Prepare navigation variables #}
{%- if prev_page is defined -%}
{%- set prev_title = prev_page.title -%}
{%- set prev_permalink = prev_page.permalink -%}
{%- set prev_html_link = '<a href="' ~ prev_page.permalink ~ '" aria_label="' ~ prev_page.title ~ '">' ~ prev_page.title ~ '</a>' -%}
{%- set prev_description = prev_page.description | default(value="") -%}
{%- endif -%}
{%- if next_page is defined -%}
{%- set next_title = next_page.title -%}
{%- set next_permalink = next_page.permalink -%}
{%- set next_html_link = '<a href="' ~ next_page.permalink ~ '" aria_label="' ~ next_page.title ~ '">' ~ next_page.title ~ '</a>' -%}
{%- set next_description = next_page.description | default(value="") -%}
{%- endif -%}
{# Replace standard variables #}
{%- set template = template
| replace(from="$SERIES_TITLE", to=series_title)
| replace(from="$SERIES_PERMALINK", to=series_permalink)
| replace(from="$SERIES_HTML_LINK", to=series_html_link)
| replace(from="$FIRST_TITLE", to=first_page.title)
| replace(from="$FIRST_HTML_LINK", to='<a href="' ~ first_page.permalink ~ '">' ~ first_page.title ~ '</a>')
| replace(from="$SERIES_PAGES_NUMBER", to=series_pages_number | as_str)
| replace(from="$SERIES_PAGE_INDEX", to=series_page_index | as_str)
| replace(from="$SERIES_PAGES_OLIST", to=series_pages_ordered_list)
| replace(from="$SERIES_PAGES_ULIST", to=series_pages_unordered_list)
-%}
{# Replace navigation variables if they exist #}
{%- if prev_page is defined -%}
{%- set template = template
| replace(from="$PREV_TITLE", to=prev_title)
| replace(from="$PREV_PERMALINK", to=prev_permalink)
| replace(from="$PREV_HTML_LINK", to=prev_html_link)
| replace(from="$PREV_DESCRIPTION", to=prev_description)
-%}
{%- endif -%}
{%- if next_page is defined -%}
{%- set template = template
| replace(from="$NEXT_TITLE", to=next_title)
| replace(from="$NEXT_PERMALINK", to=next_permalink)
| replace(from="$NEXT_HTML_LINK", to=next_html_link)
| replace(from="$NEXT_DESCRIPTION", to=next_description)
-%}
{%- endif -%}
{# Custom placeholders #}
{%- if series_section.extra.series_template_placeholders is defined -%}
{%- set missing_vars = [] -%}
{%- for placeholder in series_section.extra.series_template_placeholders -%}
{%- if placeholder in template -%}
{%- set var_name = placeholder | replace(from="$", to="") | lower -%}
{%- if page.extra.series_template_variables is defined and page.extra.series_template_variables[var_name] is defined -%}
{%- set_global template = template | replace(from=placeholder, to=page.extra.series_template_variables[var_name]) -%}
{%- else -%}
{%- set_global missing_vars = missing_vars | concat(with=var_name) -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- if missing_vars | length > 0 -%}
{%- set missing_vars_str = missing_vars | join(sep=", ") -%}
{{ throw(message="ERROR: The following variables are included in this page's series templates (`series_template_placeholders`) but have not been set in the `series_template_variables` of this page: " ~ missing_vars_str) }}
{%- endif -%}
{%- endif -%}
{# Output the processed template if not empty #}
{%- if template | length > 0 -%}
<section class="series-page-{{ template_type }}">
{{ template | markdown | safe }}
</section>
{%- endif -%}
{%- endif -%}
{% endmacro %}
{# Macro for series introduction #}
{% macro get_introduction(page, series_section, series_ordered_pages, language_strings) %}
{{ macros_series_page::process_series_template(template_type="intro", page=page, series_section=series_section, series_ordered_pages=series_ordered_pages, language_strings=language_strings) }}
{% endmacro %}
{# Macro for series outro #}
{% macro get_outro(page, series_section, series_ordered_pages, language_strings) %}
{{ macros_series_page::process_series_template(template_type="outro", page=page, series_section=series_section, series_ordered_pages=series_ordered_pages, language_strings=language_strings) }}
{% endmacro %}

View File

@@ -180,6 +180,33 @@ Current section extra: {% if current_section %}{{ current_section.extra | json_e
{% endif %}
</ul>
{#- A page is part of a series if one of the sections above (whether it is transparent or not) has the `extra.series` parameter set to true. -#}
{#- 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 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 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 -#}
{%- for section_path in section_paths | reverse -%}
{%- set section_file_exists = load_data(path=section_path, required=false) -%}
{%- if section_file_exists -%}
{%- set loaded_section = get_section(path=section_path,lang=lang) -%}
{%- if "series" in loaded_section.extra and loaded_section.extra.series -%}
{%- set_global series_section = loaded_section -%}
{%- set_global series_ordered_pages = loaded_section.pages -%}
{%- if loaded_section.paginated | default(value=0) > 0 and loaded_section.paginate_reversed -%}
{%- set_global series_ordered_pages = loaded_section.pages | reverse -%}
{%- endif -%}
{%- break -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{% if page.extra.tldr %}
<div class="admonition note">
<div class="admonition-icon admonition-icon-note"></div>
@@ -192,18 +219,48 @@ Current section extra: {% if current_section %}{{ current_section.extra | json_e
</div>
{% endif %}
{# Optional table of contents below the header #}
{#- Optional table of contents below the header -#}
{% if page.toc and macros_settings::evaluate_setting_priority(setting="toc", page=page, default_global_value=false) == "true" %}
{{ macros_toc::toc(page=page, header=true, language_strings=language_strings) }}
{% endif %}
<section class="body">
{# The replace pattern is used to enable arbitrary locations for the Table of Contents #}
{# This is Philipp Oppermann's workaround: https://github.com/getzola/zola/issues/584#issuecomment-474329637 #}
{{ page.content | replace(from="<!-- toc -->", to=macros_toc::toc(page=page, header=false, language_strings=language_strings)) | safe }}
{#- Replace series_intro placeholder -#}
{%- set content_with_intro = page.content -%}
{%- if "<!-- series_intro -->" in page.content -%}
{%- set series_intro_html = macros_series_page::get_introduction(page=page, series_section=series_section, series_ordered_pages=series_ordered_pages, language_strings=language_strings) -%}
{%- set content_with_intro = content_with_intro | replace(from="<!-- series_intro -->", to=series_intro_html) -%}
{%- elif series_section -%}
{%- set series_intro_html = macros_series_page::get_introduction(page=page, series_section=series_section, series_ordered_pages=series_ordered_pages, language_strings=language_strings) -%}
{%- set content_with_intro = series_intro_html ~ content_with_intro -%}
{%- endif -%}
{#- Handle series_outro placeholder -#}
{%- set processed_content = content_with_intro -%}
{%- if "<!-- series_outro -->" in content_with_intro -%}
{%- set series_outro_html = macros_series_page::get_outro(page=page, series_section=series_section, series_ordered_pages=series_ordered_pages, language_strings=language_strings) -%}
{%- set processed_content = processed_content | replace(from="<!-- series_outro -->", to=series_outro_html) -%}
{%- elif series_section -%}
{%- set series_outro_html = macros_series_page::get_outro(page=page, series_section=series_section, series_ordered_pages=series_ordered_pages, language_strings=language_strings) -%}
{#- We want the outro at the end of the article, but before footnote definitions -#}
{%- set footnotes_marker = '<hr><ol class="footnotes-list">' -%}
{%- if footnotes_marker in content_with_intro -%}
{%- set content_sections = processed_content | split(pat=footnotes_marker) -%}
{%- set main_content = content_sections | first -%}
{%- set footnotes_content = content_sections | slice(start=1) | join(sep=footnotes_marker) -%}
{%- set processed_content = main_content ~ series_outro_html ~ footnotes_marker ~ footnotes_content -%}
{%- else -%}
{%- set processed_content = processed_content ~ series_outro_html -%}
{%- endif -%}
{%- endif -%}
{#- Replace TOC and render final content -#}
{#- The replace pattern is used to enable arbitrary locations for the Table of Contents -#}
{#- This is Philipp Oppermann's workaround: https://github.com/getzola/zola/issues/584#issuecomment-474329637 -#}
{{ processed_content | replace(from="<!-- toc -->", to=macros_toc::toc(page=page, header=false, language_strings=language_strings)) | safe }}
</section>
{# Check if comments are enabled, checking that they are not disabled on the specific page #}
{#- 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 = "" %}
@@ -219,11 +276,6 @@ Current section extra: {% if current_section %}{{ current_section.extra | json_e
{% 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.") }}
{% endif %}
{% 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) %}
@@ -271,7 +323,11 @@ Current section extra: {% if current_section %}{{ current_section.extra | json_e
{%- endif -%}
{%- endif -%}
{# Comments #}
{#- Comments -#}
{#- 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.") }}
{% endif %}
{% if comment_system %}
{% include "partials/comments.html" %}
{% endif %}

View File

@@ -1,8 +1,9 @@
{%- set page_or_section = page | default(value=section) -%}
{# Quick navigation buttons #}
{% if macros_settings::evaluate_setting_priority(setting="quick_navigation_buttons", page=page, default_global_value=false) == "true" %}
{% if macros_settings::evaluate_setting_priority(setting="quick_navigation_buttons", page=page_or_section, default_global_value=false) == "true" %}
<div id="button-container">
{# Button to go show a floating Table of Contents #}
{% if page.toc %}
{% if page_or_section.toc %}
<div id="toc-floating-container">
<input type="checkbox" id="toc-toggle" class="toggle"/>
<label for="toc-toggle" class="overlay"></label>
@@ -10,7 +11,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M414.82-193.094q-18.044 0-30.497-12.32-12.453-12.319-12.453-30.036t12.453-30.086q12.453-12.37 30.497-12.37h392.767q17.237 0 29.927 12.487 12.69 12.486 12.69 30.203 0 17.716-12.69 29.919t-29.927 12.203H414.82Zm0-244.833q-18.044 0-30.497-12.487Q371.87-462.9 371.87-480.45t12.453-29.92q12.453-12.369 30.497-12.369h392.767q17.237 0 29.927 12.511 12.69 12.512 12.69 29.845 0 17.716-12.69 30.086-12.69 12.37-29.927 12.37H414.82Zm0-245.167q-18.044 0-30.497-12.32t-12.453-30.037q0-17.716 12.453-30.086 12.453-12.369 30.497-12.369h392.767q17.237 0 29.927 12.486 12.69 12.487 12.69 30.203 0 17.717-12.69 29.92-12.69 12.203-29.927 12.203H414.82ZM189.379-156.681q-32.652 0-55.878-22.829t-23.226-55.731q0-32.549 23.15-55.647 23.151-23.097 55.95-23.097 32.799 0 55.313 23.484 22.515 23.484 22.515 56.246 0 32.212-22.861 54.893-22.861 22.681-54.963 22.681Zm0-245.167q-32.652 0-55.878-23.134-23.226-23.135-23.226-55.623 0-32.487 23.467-55.517t56.12-23.03q32.102 0 54.721 23.288 22.62 23.288 22.62 55.775 0 32.488-22.861 55.364-22.861 22.877-54.963 22.877Zm-.82-244.833q-32.224 0-55.254-23.288-23.03-23.289-23.03-55.623 0-32.333 23.271-55.364 23.272-23.03 55.495-23.03 32.224 0 55.193 23.288 22.969 23.289 22.969 55.622 0 32.334-23.21 55.364-23.21 23.031-55.434 23.031Z"/></svg>
</label>
<div class="toc-content">
{{ macros_toc::toc(page=page, header=false, language_strings=language_strings) }}
{{ macros_toc::toc(page=page_or_section, header=false, language_strings=language_strings) }}
</div>
</div>
{% endif %}
@@ -30,13 +31,13 @@
{% endif %}
{# Add KaTeX functionality #}
{%- if macros_settings::evaluate_setting_priority(setting="katex", page=page, default_global_value=false) == "true" -%}
{%- if macros_settings::evaluate_setting_priority(setting="katex", page=page_or_section, default_global_value=false) == "true" -%}
<link rel="stylesheet" href="{{ get_url(path='katex.min.css', trailing_slash=false) | safe }}">
<script defer src="{{ get_url(path='js/katex.min.js', trailing_slash=false) | safe }}"></script>
{%- endif -%}
{# Load mermaid.js #}
{%- if macros_settings::evaluate_setting_priority(setting="mermaid", page=page, default_global_value=false) == "true" -%}
{%- if macros_settings::evaluate_setting_priority(setting="mermaid", page=page_or_section, default_global_value=false) == "true" -%}
{%- if config.extra.serve_local_mermaid | default(value=true) -%}
<script defer src="{{ get_url(path='js/mermaid.min.js', trailing_slash=false) | safe }}"></script>
{%- else -%}
@@ -45,7 +46,7 @@
{%- endif -%}
{# Add copy button to code blocks #}
{%- if macros_settings::evaluate_setting_priority(setting="copy_button", page=page, default_global_value=true) == "true" -%}
{%- if macros_settings::evaluate_setting_priority(setting="copy_button", page=page_or_section, default_global_value=true) == "true" -%}
{#- Add hidden HTML elements with the translated strings for the button's interactions -#}
<span id="copy-success" class="hidden">
{{ macros_translate::translate(key="copied", default="Copied!", language_strings=language_strings) }}
@@ -57,11 +58,11 @@
{%- endif -%}
{# JavaScript to use the "Show source or path" on code blocks shortcode: https://welpo.github.io/tabi/blog/shortcodes/#show-source-or-path #}
{%- if macros_settings::evaluate_setting_priority(setting="add_src_to_code_block", page=page, default_global_value=false) == "true" -%}
{%- if macros_settings::evaluate_setting_priority(setting="add_src_to_code_block", page=page_or_section, default_global_value=false) == "true" -%}
<script defer src="{{ get_url(path='js/addSrcToCodeBlock.min.js', trailing_slash=false) | safe }}"></script>
{%- endif -%}
{# Add backlinks to footnotes #}
{%- if macros_settings::evaluate_setting_priority(setting="footnote_backlinks", page=page, default_global_value=false) == "true" -%}
{%- if macros_settings::evaluate_setting_priority(setting="footnote_backlinks", page=page_or_section, default_global_value=false) == "true" -%}
<script defer src="{{ get_url(path='js/footnoteBacklinks.min.js', trailing_slash=false | safe )}}"></script>
{%- endif -%}

View File

@@ -1,4 +1,4 @@
{% if paginator %}
{% if paginator and paginator.number_pagers > 1 %}
<ul class="pagination">
{% if paginator.previous %}
<li class="page-item page-prev">

62
templates/series.html Normal file
View File

@@ -0,0 +1,62 @@
{% extends "base.html" %}
{% block main_content %}
{# Throw an error if the section is not flagged as a series. #}
{# This page would be displayed properly but it would become impossible for the series' child pages to reference their series. #}
{%- if "series" not in section.extra or not section.extra.series -%}
{{ throw(message="Section is not flagged as a series. Set `section.extra.series` to `true` if you want to use `series.html` template.") }}
{%- endif -%}
<main>
{%- if section.extra.header %}
{%- include "partials/home_banner.html" -%}
{% endif -%}
{%- set show_jump = false -%}
{%- set show_jump_hierarchy = macros_settings::evaluate_setting_priority(setting="show_jump_to_posts", page=section) -%}
{%- if show_jump_hierarchy == "true" -%}
{%- set show_jump = true -%}
{%- elif show_jump_hierarchy != "false" -%}
{#- Default to true if the content is long and var is unset #}
{%- if section.content | length > 2000 -%}
{%- set show_jump = true -%}
{%- endif -%}
{%- endif -%}
{%- if show_jump -%}
<div class="title-with-jump bottom-divider">
<h1 class="title-container section-title">{{ section.title }}</h1>
<a href="#posts-list" class="jump-link">{{ macros_translate::translate(key="jump_to_posts", default="Jump to posts", language_strings=language_strings) }} ↓</a>
</div>
{%- else -%}
{{ macros_page_header::page_header(title=section.title) }}
{%- endif -%}
<section class="body">
{{ section.content | safe }}
</section>
<div id="posts-list">
<h2 class="bottom-divider">
{{ macros_translate::translate(key="all_posts", default="All posts", language_strings=language_strings) }}
</h2>
{%- if paginator %}
{%- set pages = paginator.pages -%}
{% else %}
{%- set pages = section.pages -%}
{% endif -%}
{% set max_posts = section.extra.max_posts | default(value=999999) %}
{{ macros_list_posts::list_posts(posts=pages, max=max_posts, metadata="indexes", language_strings=language_strings, section_path=section.path, paginator=paginator | default(value="")) }}
</div>
{% if paginator %}
{%- include "partials/paginate.html" -%}
{% endif %}
</main>
{%- include "partials/extra_features.html" -%}
{% endblock main_content %}