🎨 refactor: turn macros into partials & sort CSS (#146)

This commit is contained in:
Óscar
2023-09-12 21:28:33 +02:00
committed by GitHub
parent cc029d0b19
commit 14ccb208cf
33 changed files with 392 additions and 421 deletions

View File

@@ -1,13 +1,7 @@
{% import "macros/add_comments.html" as macros_add_comments %}
{% import "macros/cards_pages.html" as macros_cards_pages %}
{% import "macros/create_history_url.html" as macros_create_history_url %}
{% import "macros/format_date.html" as macros_format_date %}
{% import "macros/list_posts.html" as macros_list_posts %}
{% import "macros/page_desc.html" as macros_page_desc %}
{% import "macros/page_header.html" as macros_page_header %}
{% import "macros/paginate.html" as macros_paginate %}
{% import "macros/rel_attributes.html" as macros_rel_attributes %}
{% import "macros/set_title.html" as macros_set_title %}
{% import "macros/settings.html" as macros_settings %}
{% import "macros/table_of_contents.html" as macros_toc %}
{% import "macros/translate.html" as macros_translate %}

View File

@@ -14,10 +14,10 @@
{%- set show_pages = section.pages -%}
{% endif -%}
{{ macros_cards_pages::cards_pages(pages=show_pages) }}
{%- include "partials/cards_pages.html" -%}
</main>
{% if paginator %}
{{ macros_paginate::paginate(language_strings=language_strings) }}
{%- include "partials/paginate.html" -%}
{% endif %}
{% endblock main_content %}

View File

@@ -1,7 +1,5 @@
{% macro page_header(title) %}
<h1 class="title-container section-title bottom-divider">
{{ title }}
</h1>
{% endmacro page_header %}

View File

@@ -16,4 +16,4 @@
{# Return the array of rel attributes joined by a space #}
{{- rel_attributes | join(sep=" ") -}}
{% endmacro external_links %}
{% endmacro rel_attributes %}

View File

@@ -84,7 +84,7 @@
{# Show link to remote changes if enabled #}
{% if config.extra.remote_repository_url and macros_settings::evaluate_setting_priority(setting="show_remote_changes", page=page, default_global_value=true) == "true" %}
{{ separator }}
<li><a href="{{ macros_create_history_url::create_history_url(relative_path=page.relative_path) }}" {{ blank_target }} rel="{{ rel_attributes }}">{{ macros_translate::translate(key="see_changes", default="See changes", language_strings=language_strings) }}<small></small></a></li>
<li><a href="{% include "partials/history_url.html" %}" {{ blank_target }} rel="{{ rel_attributes }}">{{ macros_translate::translate(key="see_changes", default="See changes", language_strings=language_strings) }}<small></small></a></li>
{% endif %}
{% endif %}
</ul>
@@ -141,8 +141,7 @@
{% endif %}
{% if comment_system %}
{% set automatic_loading = config.extra[comment_system].automatic_loading %}
{{ macros_add_comments::add_comments(comment_system=comment_system, automatic_loading=automatic_loading) }}
{% include "partials/comments.html" %}
{% endif %}
</article>

View File

@@ -1,5 +1,3 @@
{% macro cards_pages(pages) %}
{%- set rel_attributes = macros_rel_attributes::rel_attributes() | trim -%}
{%- if config.markdown.external_links_target_blank -%}
@@ -9,7 +7,7 @@
{%- endif -%}
<div class="cards">
{%- for page in pages %}
{%- for page in show_pages %}
<div class="card">
{% if page.extra.link_to %}
<a rel="{{ rel_attributes }}" {{ blank_target }} href={{ page.extra.link_to }}>
@@ -45,5 +43,3 @@
{% endfor -%}
</div>
{% endmacro cards_pages %}

View File

@@ -1,4 +1,4 @@
{%- macro add_comments(comment_system, automatic_loading) -%}
{% set automatic_loading = config.extra[comment_system].automatic_loading %}
<div id="comments" class="comments"
@@ -92,5 +92,3 @@
<noscript>You need JavaScript to view the comments.</noscript>
</div>
{%- endmacro add_comments -%}

View File

@@ -4,7 +4,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{# Site title #}
<title>{{ macros_set_title::set_title(language_strings=language_strings) }}</title>
<title>{%- include "partials/title.html" -%}</title>
{# Favicon #}
{% if config.extra.favicon %}

View File

@@ -1,5 +1,4 @@
{% macro create_history_url(relative_path) %}
{%- set relative_path = page.relative_path -%}
{%- set repository_url = config.extra.remote_repository_url | trim_end_matches(pat='/') -%}
{%- set branch = config.extra.remote_repository_branch | default(value="main") -%}
{%- set git_platform = config.extra.remote_repository_git_platform | default(value="auto") -%}
@@ -25,5 +24,3 @@
{%- else -%}
{{ throw(message="ERROR: Unknown, unsupported, or unspecified git platform. If you're using a custom domain, please specify the 'git_platform' in the config. If you think this is a bug, please report it: https://github.com/welpo/tabi/issues/new?assignees=&labels=bug&template=bug_report.md&title=Unsupported%20Git%20Platform%20Detected") }}
{%- endif -%}
{% endmacro %}

View File

@@ -1,25 +1,22 @@
{% macro page_desc(desc, page) %}
{%- set header = section.extra.header-%}
<div id="banner-container-home">
<div id="home-banner-text">
<h1 id="home-banner-header">{{ desc.title }}</h1>
<h1 id="home-banner-header">{{ header.title }}</h1>
<section id="banner-home-subtitle">
{{ page.content | safe }}
{{ section.content | safe }}
</section>
</div>
{%- if desc.img -%}
{%- if header.img -%}
{# Check if the image contains "$BASE_URL". This feature will be removed in the future #} {# in favour of using the proper image path. It will be a breaking change. #}
{%- if desc.img is containing("$BASE_URL") -%}
{%- set image_path = desc.img | replace(from="$BASE_URL", to=config.base_url) | safe -%}
{%- if header.img is containing("$BASE_URL") -%}
{%- set image_path = header.img | replace(from="$BASE_URL", to=config.base_url) | safe -%}
{# When the feature is removed, uncomment below to throw a descriptive error #}
{# {{ throw(message="ERROR: The image path for the header should not contain '$BASE_URL'. Please remove it and use the proper image path.") }} #}
{%- else -%}
{%- set image_path = get_url(path=desc.img, trailing_slash=false) | safe -%}
{%- set image_path = get_url(path=header.img, trailing_slash=false) | safe -%}
{%- endif -%}
<div id="image-container-home">
<img alt="the owner" id="banner-home-img" src="{{ image_path }}" />
</div>
{%- endif -%}
</div>
{% endmacro %}

View File

@@ -1,5 +1,3 @@
{% macro paginate(language_strings="") %}
{% if paginator %}
<ul class="pagination">
{% if paginator.previous %}
@@ -27,5 +25,3 @@
{% endif %}
</ul>
{% endif %}
{% endmacro paginate %}

View File

@@ -1,11 +1,9 @@
{%- macro set_title(language_strings="") -%}
{# Setup. #}
{#- Setup -#}
{%- set prefix = config.title | safe -%}
{%- set custom_separator = config.extra.separator | default(value="•") -%}
{%- set separator = " " ~ custom_separator ~ " " -%}
{# Get the base path for the current language. #}
{#- Get the base path for the current language -#}
{%- if lang != config.default_language %}
{%- set base_path = "/" ~ lang ~ "/" %}
{%- else -%}
@@ -22,20 +20,18 @@
{% elif page.title %}
{%- set suffix = page.title -%}
{% elif term.name %}
{# Individual tags. #}
{#- Individual tags -#}
{%- set suffix = term.name -%}
{% elif taxonomy.name %}
{# List of tags. #}
{#- List of tags -#}
{%- set suffix = macros_translate::translate(key=taxonomy.name, language_strings=language_strings) | capitalize -%}
{% else %}
{%- set suffix = "404" %}
{%- endif -%}
{# Return the final concatenated string. #}
{#- Return the final concatenated string -#}
{%- if config.extra.invert_title_order -%}
{{- suffix ~ separator ~ prefix -}}
{%- else -%}
{{- prefix ~ separator ~ suffix -}}
{%- endif -%}
{%- endmacro set_title -%}

View File

@@ -8,7 +8,7 @@
{% endif -%}
{%- if section.extra.header %}
{{ macros_page_desc::page_desc(desc=section.extra.header, page=section) }}
{%- include "partials/home_banner.html" -%}
{% endif -%}
<div class="list">
@@ -28,7 +28,7 @@
</main>
{% if paginator %}
{{ macros_paginate::paginate(language_strings=language_strings) }}
{%- include "partials/paginate.html" -%}
{% endif %}
{% endblock main_content %}