mirror of
https://github.com/welpo/tabi.git
synced 2025-12-14 11:48:45 +01:00
feat(serie): add info about page's serie
If the page is part of a serie, at least the title is displayed. If configured, the description and the list of the other articles of the serie can also be displayed.
This commit is contained in:
parent
2b013c6581
commit
e5c8145918
5 changed files with 83 additions and 0 deletions
|
|
@ -62,6 +62,9 @@ see_changes = "See changes"
|
|||
table_of_contents = "Table of Contents"
|
||||
load_comments = "Load comments"
|
||||
|
||||
# Serie.
|
||||
page_of_a_serie = "This article is part of the serie: "
|
||||
|
||||
# Copy code block button.
|
||||
copied = "Copied!"
|
||||
copy_code_to_clipboard = "Copy code to clipboard"
|
||||
|
|
|
|||
|
|
@ -62,6 +62,9 @@ see_changes = "Voir les modifications"
|
|||
table_of_contents = "Table des matières"
|
||||
load_comments = "Afficher les commentaires"
|
||||
|
||||
# Serie.
|
||||
page_of_a_serie = "Cet article fait partie de la série : "
|
||||
|
||||
# Copy code block button.
|
||||
copied = "Copié !"
|
||||
copy_code_to_clipboard = "Copier le code dans le presse-papier"
|
||||
|
|
|
|||
|
|
@ -238,3 +238,30 @@ details summary {
|
|||
display: inline-block;
|
||||
transform: rotate(270deg);
|
||||
}
|
||||
|
||||
.page-serie {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
|
||||
width: 100%;
|
||||
margin-top: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
border: 1px solid var(--primary-color);
|
||||
border-left-width: 0.3rem;
|
||||
border-radius: 10px;
|
||||
padding: 1rem;
|
||||
|
||||
font-family: var(--serif-font);
|
||||
|
||||
summary::marker {
|
||||
color: var(--primary-color);
|
||||
font-size: 1.3rem;
|
||||
|
||||
font-family: var(--serif-font);
|
||||
}
|
||||
|
||||
ol {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,6 +133,8 @@
|
|||
{% endif %}
|
||||
</ul>
|
||||
|
||||
{% include "partials/page_serie.html" %}
|
||||
|
||||
{% if page.extra.tldr %}
|
||||
<div class="tldr">
|
||||
<h3>TL;DR:</h3>
|
||||
|
|
|
|||
48
templates/partials/page_serie.html
Normal file
48
templates/partials/page_serie.html
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
{# We have to retrieve the first section having the `extra.serie` parameter set to true #}
|
||||
{# As a serie might be a transparent section in order to mix up its article with the one of the section just above or the root, #}
|
||||
{# there is no other way but to compute the potential path of each section related to the page and look for the first one being a serie #}
|
||||
{%- 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 -%}
|
||||
{# We identify the closest serie of the page, 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 section = get_section(path=section_path,lang=lang) -%}
|
||||
{%- if "serie" in section.extra and section.extra.serie -%}
|
||||
{%- set_global serie_section = section -%}
|
||||
{%- break -%}
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- if serie_section -%}
|
||||
{%- set page_of_a_serie = macros_translate::translate(key="page_of_a_serie", default="This article is part of the serie: ", language_strings=language_strings) -%}
|
||||
{%- if macros_settings::evaluate_setting_priority(setting="serie_page_description", page=page, section=serie_section, default_global_value="none") == "full" -%}
|
||||
<details class="page-serie">
|
||||
<summary>
|
||||
{{ page_of_a_serie }}<a href="{{ serie_section.permalink | safe }}" aria_label="{{ serie_section.title | safe }}">{{ serie_section.title }}</a>
|
||||
</summary>
|
||||
{{ serie_section.description | safe }}
|
||||
{%- set ordered_serie_pages = serie_section.pages | reverse -%}
|
||||
<nav>
|
||||
<ol>
|
||||
{%- for serie_page in ordered_serie_pages -%}
|
||||
{%- if serie_page.relative_path == page.relative_path -%}
|
||||
<li>{{ serie_page.title }}</li>
|
||||
{%- else -%}
|
||||
<li><a href="{{ serie_page.permalink | safe }}" aria-label="{{ serie_page.title | safe }}">{{ serie_page.title }}</a></li>
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
</ol>
|
||||
</nav>
|
||||
</details>
|
||||
{%- else -%}
|
||||
<div class="page-serie">
|
||||
{{ page_of_a_serie }}<a href="{{ serie_section.permalink | safe }}" aria_label="{{ serie_section.title | safe }}">{{ serie_section.title }}</a>
|
||||
</div>
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
Loading…
Add table
Add a link
Reference in a new issue