Skip to content

Commit

Permalink
fix for sections + move cards
Browse files Browse the repository at this point in the history
  • Loading branch information
welpo committed Nov 17, 2024
1 parent 2025b6a commit f47018c
Show file tree
Hide file tree
Showing 26 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ favicon_emoji = "🌱"
# Can be set at page or section levels, following the hierarchy: page > section > config. See: https://welpo.github.io/tabi/blog/mastering-tabi-settings/#settings-hierarchy
# Learn how to create these images in batch and automatically:
# https://osc.garden/blog/automating-social-media-cards-zola/
social_media_card = "social_cards/index.jpg"
social_media_card = "index.jpg"

menu = [
{ name = "blog", url = "blog", trailing_slash = true },
Expand Down
2 changes: 1 addition & 1 deletion content/_index.ca.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ max_posts = 4
projects_path = "projects/_index.ca.md"
max_projects = 3
show_projects_first = false
social_media_card = "social_cards/ca.jpg"
social_media_card = "ca.jpg"
+++

tabi és un tema de [Zola](https://www.getzola.org) ràpid, lleuger i modern. Té com a objectiu ser una pàgina personal i llar d'entrades de blog. Compta amb una puntuació perfecta de Lighthouse, disseny responsive, tema fosc i clar, shortcodes personalitzats i molt més.
2 changes: 1 addition & 1 deletion content/_index.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ max_posts = 4
projects_path = "projects/_index.es.md"
max_projects = 3
show_projects_first = false
social_media_card = "social_cards/es.jpg"
social_media_card = "es.jpg"
+++

tabi es un tema de [Zola](https://www.getzola.org) rápido, ligero y moderno. Su objetivo es ser una página personal y hogar para publicaciones de blogs. Cuenta con una puntuación perfecta en Lighthouse, diseño responsive, tema oscuro y claro, shortcodes personalizados y mucho más.
2 changes: 1 addition & 1 deletion content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ max_posts = 4
projects_path = "projects/_index.md"
max_projects = 3
show_projects_first = false
social_media_card = "social_cards/index.jpg"
social_media_card = "index.jpg"
+++

tabi is a fast, lightweight, and modern [Zola](https://www.getzola.org) theme. It aims to be a personal page and home to blog posts. It features a perfect Lighthouse score, responsive design, dark and light themes, custom shortcodes, and much more.
2 changes: 1 addition & 1 deletion content/archive/_index.ca.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ title = "Arxiu"
template = "archive.html"

[extra]
social_media_card = "archive/social_cards/ca_archive.jpg"
social_media_card = "ca_archive.jpg"
+++
2 changes: 1 addition & 1 deletion content/archive/_index.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ title = "Archivo"
template = "archive.html"

[extra]
social_media_card = "archive/social_cards/es_archive.jpg"
social_media_card = "es_archive.jpg"
+++
2 changes: 1 addition & 1 deletion content/archive/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ title = "Archive"
template = "archive.html"

[extra]
social_media_card = "archive/social_cards/archive.jpg"
social_media_card = "archive.jpg"
+++
File renamed without changes
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion content/blog/_index.ca.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ sort_by = "date"
insert_anchor_links = "left"

[extra]
social_media_card = "blog/social_cards/ca_blog.jpg"
social_media_card = "ca_blog.jpg"
show_previous_next_article_links = true
+++
2 changes: 1 addition & 1 deletion content/blog/_index.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ sort_by = "date"
insert_anchor_links = "left"

[extra]
social_media_card = "blog/social_cards/es_blog.jpg"
social_media_card = "es_blog.jpg"
show_previous_next_article_links = true
+++
2 changes: 1 addition & 1 deletion content/blog/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ sort_by = "date"
insert_anchor_links = "left"

[extra]
social_media_card = "blog/social_cards/blog.jpg"
social_media_card = "blog.jpg"
show_previous_next_article_links = true
+++
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
1 change: 0 additions & 1 deletion content/pages/about/index.ca.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ path = "/ca/about"

[extra]
quick_navigation_buttons = true
social_media_card = "social_cards/about.ca.jpg"
+++

Benvingut a la demo de [**tabi**](https://github.com/welpo/tabi), un tema per a [Zola](https://www.getzola.org/), un generador de llocs web estàtics rapidíssim.
Expand Down
1 change: 0 additions & 1 deletion content/pages/about/index.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ path = "/es/about"

[extra]
quick_navigation_buttons = true
social_media_card = "social_cards/about.es.jpg"
+++

Bienvenido a la demo de [**tabi**](https://github.com/welpo/tabi), un tema para [Zola](https://www.getzola.org/), un rapidísimo generador de sitios estáticos.
Expand Down
1 change: 0 additions & 1 deletion content/pages/about/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ path = "about"

[extra]
quick_navigation_buttons = true
social_media_card = "social_cards/about.jpg"
+++

Welcome to the demo of [**tabi**](https://github.com/welpo/tabi), a theme for [Zola](https://www.getzola.org/), a fast static site generator.
Expand Down
Binary file removed content/pages/about/social_cards/about.ca.jpg
Binary file not shown.
Binary file removed content/pages/about/social_cards/about.es.jpg
Binary file not shown.
Binary file removed content/pages/about/social_cards/about.jpg
Binary file not shown.
21 changes: 15 additions & 6 deletions templates/partials/social_media_images.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
{# Image for social media sharing #}
{%- set social_media_card = macros_settings::evaluate_setting_priority(setting="social_media_card", page=page | default(value=""), section=section | default(value=""), default_global_value="") -%}
{% if social_media_card %}
{# Try to find the image in current page, parent directories, and as absolute path #}
{% set page_path = page.colocated_path | default(value="") %}
{% set current_path = page_path ~ social_media_card %}
{# Get base path from either page or section #}
{% set base_path = "" %}
{% if section and section.path %}
{% set base_path = section.path | trim_end_matches(pat="/_index.md") %}
{% if base_path and not social_media_card is starting_with("/") %}
{% set base_path = base_path ~ "/" %}
{% endif %}
{% else %}
{% set base_path = page.colocated_path | default(value="") %}
{% endif %}

{% set current_path = base_path ~ social_media_card | trim_start_matches(pat="/") %}

{# Try parent path by removing the last directory component #}
{% set parent_path = page_path | split(pat="/") | slice(end=-2) | join(sep="/") %}
{% if parent_path %}
{% set parent_path = base_path | split(pat="/") | slice(end=-2) | join(sep="/") %}
{% if parent_path and not social_media_card is starting_with("/") %}
{% set parent_path = parent_path ~ "/" %}
{% endif %}
{% set parent_relative_path = parent_path ~ social_media_card %}
{% set parent_relative_path = parent_path ~ social_media_card | trim_start_matches(pat="/") %}

{# Check all possible locations #}
{%- set current_meta = get_image_metadata(path=current_path, allow_missing=true) -%}
Expand Down

0 comments on commit f47018c

Please sign in to comment.