mirror of
https://github.com/welpo/tabi.git
synced 2025-12-17 04:48:44 +01:00
✨ feat: add tag filtering for projects
This commit is contained in:
parent
8e1acdbba2
commit
8b28514c8b
17 changed files with 267 additions and 9 deletions
|
|
@ -18,7 +18,12 @@
|
|||
{%- set show_pages = section.pages -%}
|
||||
{% endif -%}
|
||||
|
||||
{%- include "partials/cards_pages.html" -%}
|
||||
{%- if macros_settings::evaluate_setting_priority(setting="enable_cards_tag_filtering", page=section, default_global_value=true) == "true" -%}
|
||||
{%- include "partials/filter_card_tags.html" -%}
|
||||
{%- endif -%}
|
||||
|
||||
|
||||
{%- include "partials/cards_pages.html" -%}
|
||||
</main>
|
||||
|
||||
{% if paginator %}
|
||||
|
|
|
|||
|
|
@ -92,6 +92,25 @@
|
|||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
|
||||
{% if post.extra.local_image or post.extra.remote_image %}
|
||||
<li class="post-thumbnail">
|
||||
<a href="{{ post.permalink }}">
|
||||
{% if post.extra.local_image %}
|
||||
{% set meta = get_image_metadata(path=post.extra.local_image, allow_missing=true) %}
|
||||
<img class="thumbnail-image"
|
||||
alt="{{ post.extra.local_image }}"
|
||||
src="{{ get_url(path=post.extra.local_image) }}"
|
||||
{% if meta.width %}width="{{ meta.width }}"{% endif %}
|
||||
{% if meta.height %}height="{{ meta.height }}"{% endif %}>
|
||||
{% elif post.extra.remote_image %}
|
||||
<img class="thumbnail-image"
|
||||
alt="{{ post.extra.remote_image }}"
|
||||
src="{{ post.extra.remote_image }}">
|
||||
{% endif %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if post.draft %}
|
||||
<li class="draft-label">{{ macros_translate::translate(key="draft", default="DRAFT", language_strings=language_strings) }}</li>
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ Current section extra: {% if current_section %}{{ current_section.extra | json_e
|
|||
</pre></div>
|
||||
|
||||
{% set settings_to_test = [
|
||||
"enable_cards_tag_filtering",
|
||||
"footnote_backlinks",
|
||||
"add_src_to_code_block",
|
||||
"force_codeblock_ltr",
|
||||
|
|
|
|||
|
|
@ -15,13 +15,24 @@
|
|||
|
||||
{% set target_url = page.extra.link_to | default(value=page.permalink) %}
|
||||
|
||||
<a rel="{{ rel_attributes }}" {{ blank_target }} href="{{ target_url }}" class="card">
|
||||
<div>
|
||||
<a rel="{{ rel_attributes }}"
|
||||
{{ blank_target }}
|
||||
href="{{ target_url }}"
|
||||
class="card"
|
||||
{% if page.taxonomies %}
|
||||
data-tags="{% for tax_name, terms in page.taxonomies %}{% for term in terms | unique %}{{ term | lower }}{% if not loop.last %},{% endif %}{% endfor %}{% endfor %}"
|
||||
{% 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 %}>
|
||||
<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 }}">
|
||||
<img class="card-image"
|
||||
alt="{{ page.extra.remote_image }}"
|
||||
src="{{ page.extra.remote_image }}">
|
||||
{% else %}
|
||||
<div class="card-image-placeholder"></div>
|
||||
{% endif %}
|
||||
|
|
|
|||
35
templates/partials/filter_card_tags.html
Normal file
35
templates/partials/filter_card_tags.html
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{#- Collect all terms. -#}
|
||||
{#- We don't use `get_taxonomy` so users aren't forced to use 'tags' -#}
|
||||
{% set all_terms = [] %}
|
||||
{% for page in show_pages %}
|
||||
{% if page.taxonomies %}
|
||||
{% for tax_name, terms in page.taxonomies %}
|
||||
{% for term in terms %}
|
||||
{% set_global all_terms = all_terms | concat(with=term) %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{#- Display unique terms -#}
|
||||
{%- if all_terms -%}
|
||||
<ul class="filter-controls" role="group" aria-label="{{ macros_translate::translate(key='project_filters', default='Project filters', language_strings=language_strings) }}">
|
||||
<li class="taxonomy-item no-hover-padding">
|
||||
<a id="all-projects-filter" class="no-hover-padding active"
|
||||
href="{{ get_url(path="projects", lang=lang) }}"
|
||||
data-filter="all">
|
||||
{{- macros_translate::translate(key="all_projects", default="All projects", language_strings=language_strings) -}}
|
||||
</a>
|
||||
</li>
|
||||
{% for term in all_terms | unique | sort %}
|
||||
<li class="taxonomy-item no-hover-padding">
|
||||
<a class="no-hover-padding"
|
||||
href="{{ get_taxonomy_url(kind="tags", name=term) }}"
|
||||
data-filter="{{ term | lower }}">{{ term }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
{#- Load the script -#}
|
||||
<script src="{{ get_url(path='js/filterCards.min.js', trailing_slash=false) | safe }}" async></script>
|
||||
Loading…
Add table
Add a link
Reference in a new issue