🐛 fix: allow pages within pages (#385)

main
Óscar 5 months ago committed by GitHub
parent edb087392f
commit 0bebcd1c6d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,7 +1,7 @@
+++ +++
title = "Domina la configuració de tabi: guia completa" title = "Domina la configuració de tabi: guia completa"
date = 2023-09-18 date = 2023-09-18
updated = 2024-08-28 updated = 2024-09-17
description = "Descobreix les múltiples maneres en què pots personalitzar tabi." description = "Descobreix les múltiples maneres en què pots personalitzar tabi."
[taxonomies] [taxonomies]
@ -25,11 +25,12 @@ tabi té una jerarquia que permet personalitzar el teu lloc a diferents nivells.
1. **Configuracions globals**: Aquestes són les configuracions que s'apliquen a tot el teu lloc. Es configuren a `config.toml`. 1. **Configuracions globals**: Aquestes són les configuracions que s'apliquen a tot el teu lloc. Es configuren a `config.toml`.
2. **Configuracions de secció**: Aquestes són les configuracions que s'apliquen a una secció del teu lloc (per exemple, `/blog` o `/projects`). Es configuren a la metainformació de l'arxiu `_index.md` de la secció. 2. **Configuracions de secció**: Aquestes són les configuracions que s'apliquen a una secció del teu lloc (per exemple, `/blog` o `/projects`). Es configuren a la metainformació de l'arxiu `_index.md` de la secció.
3. **Configuracions de pàgina**: Aquestes són les configuracions que s'apliquen a una sola pàgina. Es configuren a la metainformació de la pàgina. 3. **Configuració de la pàgina «pare»**: Per a pàgines anidades (pàgines dins de pàgines), aquestes són les configuracions de la pàgina que les conté.
4. **Configuracions de pàgina**: Aquestes són les configuracions que s'apliquen a una sola pàgina. Es configuren a la metainformació de la pàgina.
En tots els casos, les opcions de tabi es configuren a la secció `[extra]`. En tots els casos, les opcions de tabi es configuren a la secció `[extra]`.
Per a les configuracions que segueixen aquesta jerarquia, el valor establert a una pàgina reemplaça el valor d'una secció, que al seu torn reemplaça el valor global. En resum: com més específica sigui la configuració, més prioritat tindrà, o `pàgina > secció > config.toml`. Per a les configuracions que segueixen aquesta jerarquia, el valor establert a una pàgina reemplaça el valor d'una secció, que al seu torn reemplaça el valor global. En resum: com més específica sigui la configuració, més prioritat tindrà, o `pàgina > pàgina pare/secció > config.toml`.
--- ---

@ -1,7 +1,7 @@
+++ +++
title = "Domina la configuración de tabi: guía completa" title = "Domina la configuración de tabi: guía completa"
date = 2023-09-18 date = 2023-09-18
updated = 2024-08-28 updated = 2024-09-17
description = "Descubre las múltiples maneras en que puedes personalizar tabi." description = "Descubre las múltiples maneras en que puedes personalizar tabi."
[taxonomies] [taxonomies]
@ -25,11 +25,12 @@ tabi tiene una jerarquía que te permite personalizar tu sitio en diferentes niv
1. **Configuraciones globales**: Estas son las configuraciones que se aplican a todo tu sitio. Se establecen en `config.toml`. 1. **Configuraciones globales**: Estas son las configuraciones que se aplican a todo tu sitio. Se establecen en `config.toml`.
2. **Configuraciones de sección**: Estas son las configuraciones que se aplican a una sección de tu sitio (por ejemplo, `/blog` o `/projects`). Se establecen en la metainformación del archivo `_index.md` de la sección. 2. **Configuraciones de sección**: Estas son las configuraciones que se aplican a una sección de tu sitio (por ejemplo, `/blog` o `/projects`). Se establecen en la metainformación del archivo `_index.md` de la sección.
3. **Configuraciones de página**: Estas son las configuraciones que se aplican a una sola página. Se establecen en la metainformación de la página. 3. **Configuración de la página «padre»**: Para páginas anidadas (páginas dentro de páginas), estas son las configuraciones de la página que las contiene.
4. **Configuraciones de página**: Estas son las configuraciones que se aplican a una sola página. Se establecen en la metainformación de la página.
En todos los casos, las opciones de tabi se establecen en la sección `[extra]`. En todos los casos, las opciones de tabi se establecen en la sección `[extra]`.
Para las configuraciones que siguen esta jerarquía, el valor establecido en una página reemplaza el valor de una sección, que a su vez reemplaza el valor global. En resumen: cuanto más específica sea la configuración, mayor prioridad tendrá, o `página > sección > config.toml`. Para las configuraciones que siguen esta jerarquía, el valor establecido en una página reemplaza el valor de una sección, que a su vez reemplaza el valor global. En resumen: cuanto más específica sea la configuración, mayor prioridad tendrá, o `página > página padre/sección > config.toml`.
--- ---

@ -1,7 +1,7 @@
+++ +++
title = "Mastering tabi Settings: A Comprehensive Guide" title = "Mastering tabi Settings: A Comprehensive Guide"
date = 2023-09-18 date = 2023-09-18
updated = 2024-08-28 updated = 2024-09-17
description = "Discover the many ways you can customise your tabi site." description = "Discover the many ways you can customise your tabi site."
[taxonomies] [taxonomies]
@ -25,11 +25,12 @@ tabi has a hierarchy that allows you to customise your site at different levels.
1. **Global settings**: These are the settings that apply to your entire site. They are set in `config.toml`. 1. **Global settings**: These are the settings that apply to your entire site. They are set in `config.toml`.
2. **Section settings**: These are the settings that apply to a section of your site (e.g.`/blog` or `/projects`). They are set in the front matter of the `_index.md` file of the section. 2. **Section settings**: These are the settings that apply to a section of your site (e.g.`/blog` or `/projects`). They are set in the front matter of the `_index.md` file of the section.
3. **Page settings**: These are the settings that apply to a single page. They are set in the front matter of the page. 3. **Parent page settings**: For nested pages (pages within pages), these are the settings from the parent page.
4. **Page settings**: These are the settings that apply to a single page. They are set in the front matter of the page.
In all cases, tabi's settings are set in the `[extra]` section. In all cases, tabi's settings are set in the `[extra]` section.
For settings which follow this hierarchy, the value set on a page overrides the value for a section, which overrides the global value. In short: the more specific the setting, the higher priority it has, or `page > section > config.toml`. For settings which follow this hierarchy, the value set on a page overrides the value for a section, which overrides the global value. In short: the more specific the setting, the higher priority it has, or `page > parent page/section > config.toml`.
--- ---

@ -14,9 +14,38 @@ Parameters:
{%- if section -%} {%- if section -%}
{%- set current_section = section -%} {%- set current_section = section -%}
{%- elif page -%} {%- elif page -%}
{%- set current_section = "" -%}
{#- Retrieve last ancestor to determine current section, if applicable -#} {#- Retrieve last ancestor to determine current section, if applicable -#}
{%- set last_ancestor = page.ancestors | slice(start=-1) %} {%- if page.ancestors | length > 0 -%}
{%- set current_section = get_section(path=last_ancestor.0, metadata_only=true) %} {%- set last_ancestor = page.ancestors | slice(start=-1) -%}
{%- set_global current_section = get_section(path=last_ancestor.0, metadata_only=true) -%}
{%- else -%}
{#- We're likely in a nested page. Try to find the parent page or nearest section. -#}
{%- set components = page.components -%}
{%- for i in range(start=1, end=components | length) -%}
{%- if lang == config.default_language -%}
{%- set potential_path = components | slice(end=components | length - i) | join(sep="/") -%}
{%- set potential_page = potential_path ~ "/index.md" -%}
{%- set potential_section = potential_path ~ "/_index.md" -%}
{%- else -%}
{%- set potential_path = components | slice(start=1, end=components | length - i) | join(sep="/") -%}
{%- set potential_page = potential_path ~ "/index." ~ lang ~ ".md" -%}
{%- set potential_section = potential_path ~ "/_index." ~ lang ~ ".md" -%}
{%- endif -%}
{#- Check for parent page first. -#}
{%- set page_data = load_data(path=potential_page, required=false) -%}
{%- if page_data -%}
{%- set_global current_section = get_page(path=potential_page) -%}
{%- break -%}
{%- endif -%}
{#- No parent page, check for section. -#}
{%- set section_data = load_data(path=potential_section, required=false) -%}
{%- if section_data -%}
{%- set_global current_section = get_section(path=potential_section, metadata_only=true) -%}
{%- break -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endif -%} {%- endif -%}
{%- set priority_order = [ {%- set priority_order = [

@ -12,48 +12,94 @@
{%- endif -%} {%- endif -%}
{# Debugging #} {# Debugging #}
{# {% set last_ancestor = page.ancestors | slice(start=-1) %} {# <div><pre>
{% set current_section = get_section(path=last_ancestor.0) %} Page path: {{ page.path }}
Page components: {{ page.components | join(sep=", ") }}
{% set settings_to_test = [ Page ancestors: {{ page.ancestors | join(sep=", ") }}
"footnote_backlinks", Current language: {{ lang }}
"add_src_to_code_block", Default language: {{ config.default_language }}
"copy_button", Current section: {% if current_section %}{{ current_section.path }}{% else %}None{% endif %}
"katex", Page extra: {{ page.extra | json_encode() }}
"quick_navigation_buttons", {% if section -%}
"show_reading_time", {%- set current_section = section -%}
"show_date", {%- elif page -%}
"show_author", {%- set current_section = "" -%}
"show_remote_changes", {%- if page.ancestors | length > 0 -%}
"toc", {%- set last_ancestor = page.ancestors | slice(start=-1) -%}
"show_previous_next_article_links", {%- set_global current_section = get_section(path=last_ancestor.0, metadata_only=true) -%}
"invert_previous_next_article_links", {%- else -%}
"previous_next_article_links_full_width", {%- set components = page.components -%}
"enable_csp", {%- for i in range(start=1, end=components | length) -%}
] %} {%- if lang == config.default_language -%}
{%- set potential_path = components | slice(end=components | length - i) | join(sep="/") -%}
<table> {%- set potential_page = potential_path ~ "/index.md" -%}
<thead> {%- set potential_section = potential_path ~ "/_index.md" -%}
<tr> {%- else -%}
<th>setting</th> {%- set potential_path = components | slice(start=1, end=components | length - i) | join(sep="/") -%}
<th>page</th> {%- set potential_page = potential_path ~ "/index." ~ lang ~ ".md" -%}
<th>section</th> {%- set potential_section = potential_path ~ "/_index." ~ lang ~ ".md" -%}
<th>config</th> {%- endif -%}
<th>macro output</th> Checking parent page: {{ potential_page }}
</tr> {%- set page_data = load_data(path=potential_page, required=false) -%}
</thead> {%- if page_data -%}
<tbody> {%- set_global current_section = get_page(path=potential_page) %}
{% for setting in settings_to_test %} Parent page found: {{ current_section.path }}
{%- break -%}
{%- endif -%}
Checking section: {{ potential_section }}
{%- set section_data = load_data(path=potential_section, required=false) -%}
{%- if section_data -%}
{%- set_global current_section = get_section(path=potential_section, metadata_only=true) -%}
Section found: {{ current_section.path }}
{%- break -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endif %}
Found nearest parent/section: {% if current_section %}{{ current_section.path }}{% else %}None{% endif %}
Current section extra: {% if current_section %}{{ current_section.extra | json_encode() }}{% else %}None{% endif %}
</pre></div>
{% set settings_to_test = [
"footnote_backlinks",
"add_src_to_code_block",
"copy_button",
"katex",
"quick_navigation_buttons",
"show_reading_time",
"show_date",
"show_author",
"show_remote_changes",
"toc",
"show_previous_next_article_links",
"invert_previous_next_article_links",
"previous_next_article_links_full_width",
"enable_csp",
] %}
<table>
<thead>
<tr> <tr>
<td><code>{{ setting }}</code></td> <th>setting</th>
<td>{{ page.extra[setting] | default(value="⬛") }}</td> <th>page</th>
<td>{{ current_section.extra[setting] | default(value="⬛") }}</td> <th>section</th>
<td>{{ config.extra[setting] | default(value="⬛") }}</td> <th>config</th>
<td>{{ macros_settings::evaluate_setting_priority(setting=setting, page=page) }}</td> <th>macro output</th>
</tr> </tr>
{% endfor %} </thead>
</tbody> <tbody>
</table> #} {% for setting in settings_to_test %}
<tr>
<td><code>{{ setting }}</code></td>
<td>{{ page.extra[setting] | default(value="⬛") }}</td>
<td>{{ current_section.extra[setting] | default(value="⬛") }}</td>
<td>{{ config.extra[setting] | default(value="⬛") }}</td>
<td>{{ macros_settings::evaluate_setting_priority(setting=setting, page=page) }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div> #}
{# {{ __tera_context }} #} {# {{ __tera_context }} #}
{# End debugging #} {# End debugging #}

Loading…
Cancel
Save