🎨 refactor: turn macros into partials & sort CSS (#146)
This commit is contained in:
@@ -1,96 +0,0 @@
|
||||
{%- macro add_comments(comment_system, automatic_loading) -%}
|
||||
|
||||
<div id="comments" class="comments"
|
||||
|
||||
{% if comment_system == "giscus" %}
|
||||
data-repo="{{ config.extra.giscus.repo }}"
|
||||
data-repo-id="{{ config.extra.giscus.repo_id }}"
|
||||
data-category="{{ config.extra.giscus.category }}"
|
||||
data-category-id="{{ config.extra.giscus.category_id }}"
|
||||
{% if config.extra.giscus.mapping == "slug" %}
|
||||
data-mapping="specific"
|
||||
data-term="{{ page.slug }}"
|
||||
{% else %}
|
||||
data-mapping="{{ config.extra.giscus.mapping }}"
|
||||
{% endif %}
|
||||
data-strict="{{ config.extra.giscus.strict_title_matching }}"
|
||||
data-reactions-enabled="{{ config.extra.giscus.enable_reactions }}"
|
||||
{% if config.extra.giscus.comment_box_above_comments %}
|
||||
data-input-position="top"
|
||||
{% else %}
|
||||
data-input-position="bottom"
|
||||
{% endif %}
|
||||
data-light-theme="{{ config.extra.giscus.light_theme }}"
|
||||
data-dark-theme="{{ config.extra.giscus.dark_theme }}"
|
||||
{% if config.extra.giscus.lang %}
|
||||
data-lang="{{ config.extra.giscus.lang }}"
|
||||
{% else %}
|
||||
data-lang="{{ lang }}"
|
||||
{% endif %}
|
||||
data-lazy-loading="{{ config.extra.giscus.lazy_loading }}"
|
||||
>
|
||||
|
||||
{% elif comment_system == "utterances" %}
|
||||
data-repo="{{ config.extra.utterances.repo }}"
|
||||
{% if config.extra.utterances.issue_term == "slug" %}
|
||||
data-issue-term="{{ page.slug }}"
|
||||
{% else %}
|
||||
data-issue-term="{{ config.extra.utterances.issue_term }}"
|
||||
{% endif %}
|
||||
data-label="{{ config.extra.utterances.label }}"
|
||||
data-light-theme="{{ config.extra.utterances.light_theme }}"
|
||||
data-dark-theme="{{ config.extra.utterances.dark_theme }}"
|
||||
data-lazy-loading="{{ config.extra.utterances.lazy_loading }}"
|
||||
>
|
||||
|
||||
{% elif comment_system == "hyvortalk" %}
|
||||
data-website-id="{{ config.extra.hyvortalk.website_id }}"
|
||||
{% if config.extra.hyvortalk.page_id_is_slug %}
|
||||
data-page-id="{{ page.slug }}"
|
||||
{% else %}
|
||||
data-page-id="{{ current_url }}"
|
||||
{% endif %}
|
||||
{% if config.extra.hyvortalk.lang %}
|
||||
data-page-language="{{ config.extra.hyvortalk.lang }}"
|
||||
{% else %}
|
||||
data-page-language="{{ lang }}"
|
||||
{% endif %}
|
||||
data-page-author="{{ config.extra.hyvortalk.page_author }}"
|
||||
{% if config.extra.hyvortalk.lazy_loading %}
|
||||
data-loading="lazy"
|
||||
{% else %}
|
||||
data-loading="default"
|
||||
{% endif %}
|
||||
>
|
||||
|
||||
{% elif comment_system == "isso" %}
|
||||
data-endpoint-url="{{ config.extra.isso.endpoint_url }}"
|
||||
{% if config.extra.isso.page_id_is_slug %}
|
||||
data-isso-id="{{ page.slug }}"
|
||||
data-title="{{ page.slug }}"
|
||||
{% endif %}
|
||||
{% if config.extra.isso.lang %}
|
||||
data-page-language="{{ config.extra.isso.lang }}"
|
||||
{% else %}
|
||||
data-page-language="{{ lang }}"
|
||||
{% endif %}
|
||||
data-max-comments-top="{{ config.extra.isso.max_comments_top }}"
|
||||
data-max-comments-nested="{{ config.extra.isso.max_comments_nested }}"
|
||||
data-avatar="{{ config.extra.isso.avatar }}"
|
||||
data-voting="{{ config.extra.isso.voting }}"
|
||||
data-page-author-hashes="{{ config.extra.isso.page_author_hashes }}"
|
||||
data-lazy-loading="{{ config.extra.isso.lazy_loading }}"
|
||||
>
|
||||
{% endif %}
|
||||
|
||||
{% if automatic_loading %}
|
||||
<script src="{{ get_url(path='js/' ~ comment_system ~ '.min.js', trailing_slash=false) | safe }}" async></script>
|
||||
{% else %}
|
||||
<button id="load-comments" class="load-comments-button" data-script-src="{{ get_url(path='js/' ~ comment_system ~ '.min.js', trailing_slash=false) | safe }}">{{ macros_translate::translate(key="load_comments", default="Load comments", language_strings=language_strings) }}</button>
|
||||
<script src="{{ get_url(path='js/loadComments.min.js', trailing_slash=false) | safe }}" async></script>
|
||||
{% endif %}
|
||||
|
||||
<noscript>You need JavaScript to view the comments.</noscript>
|
||||
</div>
|
||||
|
||||
{%- endmacro add_comments -%}
|
@@ -1,49 +0,0 @@
|
||||
{% macro cards_pages(pages) %}
|
||||
|
||||
{%- set rel_attributes = macros_rel_attributes::rel_attributes() | trim -%}
|
||||
|
||||
{%- if config.markdown.external_links_target_blank -%}
|
||||
{%- set blank_target = "target=_blank" -%}
|
||||
{%- else -%}
|
||||
{%- set blank_target = "" -%}
|
||||
{%- endif -%}
|
||||
|
||||
<div class="cards">
|
||||
{%- for page in pages %}
|
||||
<div class="card">
|
||||
{% if page.extra.link_to %}
|
||||
<a rel="{{ rel_attributes }}" {{ blank_target }} href={{ page.extra.link_to }}>
|
||||
{% endif %}
|
||||
{% if page.extra.local_image %}
|
||||
{% set meta = get_image_metadata(path=page.extra.local_image, allow_missing=true) %}
|
||||
<img class="card-image" alt={{ page.extra.local_image }} src="{{ get_url(path=page.extra.local_image) }}" {% if meta.width %}width="{{ meta.width }}" {% endif %} {% if meta.height %}height="{{ meta.height }}" {% endif %}>
|
||||
{% elif page.extra.remote_image %}
|
||||
<img class="card-image" alt={{ page.extra.remote_image }} src="{{ page.extra.remote_image }}">
|
||||
{% else %}
|
||||
<div class="card-image-placeholder"></div>
|
||||
{% endif %}
|
||||
{% if page.extra.link_to %}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
<div class="card-info">
|
||||
<h2 class="card-title">
|
||||
{% if page.extra.link_to %}
|
||||
<a rel="{{ rel_attributes }}" {{ blank_target }} href={{ page.extra.link_to }}>{{page.title}}</a>
|
||||
{% else %}
|
||||
<a href={{ page.permalink }}>{{page.title}}</a>
|
||||
{% endif %}
|
||||
</h2>
|
||||
|
||||
<div class="card-description">
|
||||
{% if page.description %}
|
||||
{{ page.description }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endfor -%}
|
||||
</div>
|
||||
|
||||
{% endmacro cards_pages %}
|
@@ -1,29 +0,0 @@
|
||||
{% macro create_history_url(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") -%}
|
||||
|
||||
{# Auto-detect the git platform based on the URL#}
|
||||
{%- if git_platform == "auto" %}
|
||||
{%- if repository_url is containing("github.") -%}
|
||||
{%- set git_platform = "github" -%}
|
||||
{%- elif repository_url is containing("gitlab.") -%}
|
||||
{%- set git_platform = "gitlab" -%}
|
||||
{%- elif repository_url is matching("(gitea\.|codeberg\.)") -%}
|
||||
{%- set git_platform = "gitea" -%}
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
|
||||
{# Generate the commit history URL based on the git platform #}
|
||||
{%- if git_platform == "github" -%}
|
||||
{{ repository_url ~ '/commits/' ~ branch ~ '/content/' }}{{ relative_path | urlencode }}
|
||||
{%- elif git_platform == "gitlab" -%}
|
||||
{{ repository_url ~ '/-/commits/' ~ branch ~ '/' }}{{ relative_path | urlencode }}
|
||||
{%- elif git_platform in ["gitea", "codeberg"] -%}
|
||||
{{ repository_url ~ '/commits/branch/' ~ branch ~ '/' }}{{ relative_path | urlencode }}
|
||||
{%- 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 %}
|
@@ -1,25 +0,0 @@
|
||||
{% macro page_desc(desc, page) %}
|
||||
|
||||
<div id="banner-container-home">
|
||||
<div id="home-banner-text">
|
||||
<h1 id="home-banner-header">{{ desc.title }}</h1>
|
||||
<section id="banner-home-subtitle">
|
||||
{{ page.content | safe }}
|
||||
</section>
|
||||
</div>
|
||||
{%- if desc.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 -%}
|
||||
{# 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 -%}
|
||||
{%- endif -%}
|
||||
<div id="image-container-home">
|
||||
<img alt="the owner" id="banner-home-img" src="{{ image_path }}" />
|
||||
</div>
|
||||
{%- endif -%}
|
||||
</div>
|
||||
|
||||
{% endmacro %}
|
@@ -1,7 +1,5 @@
|
||||
{% macro page_header(title) %}
|
||||
|
||||
<h1 class="title-container section-title bottom-divider">
|
||||
{{ title }}
|
||||
</h1>
|
||||
|
||||
{% endmacro page_header %}
|
||||
|
@@ -1,31 +0,0 @@
|
||||
{% macro paginate(language_strings="") %}
|
||||
|
||||
{% if paginator %}
|
||||
<ul class="pagination">
|
||||
{% if paginator.previous %}
|
||||
<li class="page-item page-prev">
|
||||
<a href="{{ paginator.previous }}" class="page-link" aria-label="{{ macros_translate::translate(key="prev", default="Prev", language_strings=language_strings) }}">← {{ macros_translate::translate(key="prev", default="Prev", language_strings=language_strings) }}</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item page-prev">
|
||||
<span class="page-link disabled" aria-disabled="true" aria-label="{{ macros_translate::translate(key="prev", default="Prev", language_strings=language_strings) }} (disabled)">← {{ macros_translate::translate(key="prev", default="Prev", language_strings=language_strings) }}</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
<li class="page-item page-numbers">
|
||||
{{ paginator.current_index }} {{ macros_translate::translate(key="of", default="of", language_strings=language_strings) }} {{ paginator.number_pagers }}
|
||||
</li>
|
||||
|
||||
{% if paginator.next %}
|
||||
<li class="page-item page-next">
|
||||
<a href="{{ paginator.next }}" class="page-link" aria-label="{{ macros_translate::translate(key="next", default="Next", language_strings=language_strings) }}">{{ macros_translate::translate(key="next", default="Next", language_strings=language_strings) }} →</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item page-next">
|
||||
<span class="page-link disabled" aria-disabled="true" aria-label="{{ macros_translate::translate(key="next", default="Next", language_strings=language_strings) }} (disabled)">{{ macros_translate::translate(key="next", default="Next", language_strings=language_strings) }} →</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
{% endmacro paginate %}
|
@@ -16,4 +16,4 @@
|
||||
{# Return the array of rel attributes joined by a space #}
|
||||
{{- rel_attributes | join(sep=" ") -}}
|
||||
|
||||
{% endmacro external_links %}
|
||||
{% endmacro rel_attributes %}
|
||||
|
@@ -1,41 +0,0 @@
|
||||
{%- macro set_title(language_strings="") -%}
|
||||
|
||||
{# 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. #}
|
||||
{%- if lang != config.default_language %}
|
||||
{%- set base_path = "/" ~ lang ~ "/" %}
|
||||
{%- else -%}
|
||||
{%- set base_path = "/" %}
|
||||
{%- endif %}
|
||||
|
||||
{%- if current_path and current_path == base_path -%}
|
||||
{%- set suffix = "" -%}
|
||||
{%- set separator = "" -%}
|
||||
{% elif title %}
|
||||
{%- set suffix = title -%}
|
||||
{% elif section.title -%}
|
||||
{%- set suffix = section.title -%}
|
||||
{% elif page.title %}
|
||||
{%- set suffix = page.title -%}
|
||||
{% elif term.name %}
|
||||
{# Individual tags. #}
|
||||
{%- set suffix = term.name -%}
|
||||
{% elif taxonomy.name %}
|
||||
{# 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. #}
|
||||
{%- if config.extra.invert_title_order -%}
|
||||
{{- suffix ~ separator ~ prefix -}}
|
||||
{%- else -%}
|
||||
{{- prefix ~ separator ~ suffix -}}
|
||||
{%- endif -%}
|
||||
|
||||
{%- endmacro set_title -%}
|
Reference in New Issue
Block a user