Skip to content

Commit

Permalink
add jump to posts
Browse files Browse the repository at this point in the history
  • Loading branch information
welpo committed Oct 25, 2024
1 parent a82155f commit ab95d5b
Show file tree
Hide file tree
Showing 25 changed files with 78 additions and 5 deletions.
5 changes: 5 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ show_date = true
# "both" - Show both the original date and the last updated date.
post_listing_date = "date"

# Show "Jump to posts" link next to series' title.
# By default, the link appears automatically when a series description exceeds 2000 characters.
# 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
# show_jump_to_posts = true

# Determines if indexes should be increasing (false) or decreasing (true) in series' posts list.
# It has only effect if the section uses indexes metadata (which is only the case for series as of now).
# Can be set at section levels, following the hierarchy: section > config. See: https://welpo.github.io/tabi/blog/mastering-tabi-settings/#settings-hierarchy
Expand Down
12 changes: 8 additions & 4 deletions content/blog/series/03-series-cheat-sheet/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ tags = ["showcase", "tutorial", "FAQ"]
series_page_introduction_variables = { position = "third", foo = "FOO FOO FOO!!!"}

+++
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

## Jump to Posts Feature

When a series has a description over 2000 characters, a "Jump to posts" link automatically appears next to the series title:

##### TODO: Add screenshot with final design

To force the feature on or off, use the `show_jump_to_posts` option in the `[extra]` section of your section (series) or in `config.toml`. This setting follows [the hierarchy](@blog/mastering-tabi-settings/index.md#settings-hierarchy).
1 change: 1 addition & 0 deletions content/blog/series/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ transparent = true
[extra]
series = true
quick_navigation_buttons = true
show_jump_to_posts = true
post_listing_index_reversed = false

series_page_introduction_placeholders = ["$POSITION", "$FOO", "$BAR"]
Expand Down
1 change: 1 addition & 0 deletions i18n/ar.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ few_results = "تم العثور على $NUMBER نتائج" # for 3 to 10 searc
many_results = "تم العثور على $NUMBER نتيجة" # 11 or more search results.

# Navigation.
jump_to_posts = "الانتقال إلى المنشورات"
read_more = "إقرأ المزيد"
one_posts = "تدوينة واحدة" #One blog post.
two_posts = "تدوينتين" #Two blog posts.
Expand Down
1 change: 1 addition & 0 deletions i18n/ca.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ one_results = "$NUMBER resultat" # "1 result"
many_results = "$NUMBER resultats" # "3 results"

# Navigation.
jump_to_posts = "Saltar als articles"
read_more = "Llegir més"
one_posts = "$NUMBER entrada"
many_posts = "$NUMBER entrades"
Expand Down
1 change: 1 addition & 0 deletions i18n/de.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ one_results = "$NUMBER Ergebnis" # "1 result"
many_results = "$NUMBER Ergebnisse" # "3 results"

# Navigation.
jump_to_posts = "Zu den Beiträgen springen"
read_more = "Weiterlesen"
one_posts = "$NUMBER Beitrag"
many_posts = "$NUMBER Beiträge"
Expand Down
1 change: 1 addition & 0 deletions i18n/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ one_results = "$NUMBER result" # "1 result"
many_results = "$NUMBER results" # "3 results"

# Navigation.
jump_to_posts = "Jump to posts"
read_more = "Read more"
one_posts = "$NUMBER post"
many_posts = "$NUMBER posts" # "3 posts"
Expand Down
1 change: 1 addition & 0 deletions i18n/es.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ one_results = "$NUMBER resultado"
many_results = "$NUMBER resultados"

# Navigation.
jump_to_posts = "Saltar a las entradas"
read_more = "Leer más"
one_posts = "$NUMBER entrada"
many_posts = "$NUMBER entradas"
Expand Down
1 change: 1 addition & 0 deletions i18n/et.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ one_results = "$NUMBER tulemus" # "1 result"
many_results = "$NUMBER tulemust" # "3 results"

# Navigation.
jump_to_posts = "Hüppa postitusteni"
read_more = "Loe edasi"
one_posts = "$NUMBER postitus"
many_posts = "$NUMBER postitust" # "3 posts"
Expand Down
1 change: 1 addition & 0 deletions i18n/fa.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ one_results = "$NUMBER نتیجه" # "1 result"
many_results = "$NUMBER نتیجه" # "3 results"

# Navigation.
jump_to_posts = "پرش به نوشته‌ها"
read_more = "ادامه مطلب"
one_posts = "$NUMBER مطلب"
many_posts = "$NUMBER مطلب" # "3 posts"
Expand Down
1 change: 1 addition & 0 deletions i18n/fr.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ one_results = "$NUMBER résultat" # "1 result"
many_results = "$NUMBER résultats" # "3 results"

# Navigation.
jump_to_posts = "Aller aux articles"
read_more = "Lire plus"
one_posts = "$NUMBER article"
many_posts = "$NUMBER articles"
Expand Down
1 change: 1 addition & 0 deletions i18n/hi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ one_results = "$NUMBER परिणाम" # "1 result"
many_results = "$NUMBER परिणाम" # "3 results"

# Navigation.
jump_to_posts = "पोस्ट पर जाएं"
read_more = "और पढ़ें"
one_posts = "$NUMBER पोस्ट"
many_posts = "$NUMBER पोस्ट्स"
Expand Down
1 change: 1 addition & 0 deletions i18n/it.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ one_results = "$NUMBER risultato"
many_results = "$NUMBER risultati"

# Navigation.
jump_to_posts = "Vai ai post"
read_more = "Leggi di più"
one_posts = "$NUMBER post"
many_posts = "$NUMBER post"
Expand Down
1 change: 1 addition & 0 deletions i18n/ja.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ one_results = "$NUMBER 結果" # "1 result"
many_results = "$NUMBER 結果" # "3 results"

# Navigation.
jump_to_posts = "投稿へジャンプ"
read_more = "続きを読む"
one_posts = "$NUMBER 投稿"
many_posts = "$NUMBER 投稿"
Expand Down
1 change: 1 addition & 0 deletions i18n/ko.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ one_results = "$NUMBER 결과" # "1 result"
many_results = "$NUMBER 결과" # "3 results"

# Navigation.
jump_to_posts = "게시물로 이동"
read_more = "더 읽기"
one_posts = "$NUMBER 게시물"
many_posts = "$NUMBER 게시물"
Expand Down
1 change: 1 addition & 0 deletions i18n/nl.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ one_results = "$NUMBER resultaat" # "1 result"
many_results = "$NUMBER resultaten" # "3 results"

# Navigation.
jump_to_posts = "Naar berichten springen"
read_more = "Lees meer"
one_posts = "$NUMBER bericht" # "1 post"
many_posts = "$NUMBER berichten" # "3 posts"
Expand Down
1 change: 1 addition & 0 deletions i18n/or.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ one_results = "$NUMBER ପରିଣାମ" # "1 result"
many_results = "$NUMBER ପରିଣାମଗୁଡ଼ିକ" # "3 results"

# Navigation.
jump_to_posts = "ପୋଷ୍ଟକୁ ଯାଆନ୍ତୁ"
read_more = "ଆହୁରି ପଢ଼ନ୍ତୁ"
one_posts = "$NUMBER ପୋଷ୍ଟ"
many_posts = "$NUMBER ପୋଷ୍ଟଗୁଡ଼ିକ" # "3 posts"
Expand Down
1 change: 1 addition & 0 deletions i18n/pt-PT.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ one_results = "$NUMBER resultado" # "1 result"
many_results = "$NUMBER resultados" # "3 results"

# Navigation.
jump_to_posts = "Ir para as publicações"
read_more = "Ler mais"
one_posts = "$NUMBER publicação"
many_posts = "$NUMBER publicações"
Expand Down
1 change: 1 addition & 0 deletions i18n/ru.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ few_results = "$NUMBER результата" # 2, 3, 4 but not 12-14
many_results = "$NUMBER результатов" # 5-9, 0, 11-14, and others

# Navigation.
jump_to_posts = "Перейти к записям"
read_more = "Читать далее"
post = "пост"
one_posts = "$NUMBER пост"
Expand Down
1 change: 1 addition & 0 deletions i18n/uk.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ few_results = "$NUMBER результати"
many_results = "$NUMBER результатів"

# Navigation.
jump_to_posts = "Перейти до дописів"
read_more = "Читати далі"
one_posts = "$NUMBER пост"
few_posts = "$NUMBER пости" # 2, 3, 4 but not 12-14
Expand Down
1 change: 1 addition & 0 deletions i18n/zh-Hans.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ one_results = "$NUMBER 个结果"
many_results = "$NUMBER 个结果"

# Navigation.
jump_to_posts = "跳转到文章"
read_more = "阅读全文"
one_posts = "$NUMBER 篇文章"
many_posts = "$NUMBER 篇文章"
Expand Down
1 change: 1 addition & 0 deletions i18n/zh-Hant.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ one_results = "$NUMBER 個結果"
many_results = "$NUMBER 個結果"

# Navigation.
jump_to_posts = "跳轉到文章"
read_more = "閱讀全文"
one_posts = "$NUMBER 篇文章"
many_posts = "$NUMBER 篇文章"
Expand Down
21 changes: 21 additions & 0 deletions sass/parts/_misc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,24 @@ details summary {
.mermaid .node .label {
max-width: none !important;
}

.title-with-jump {
display: flex;
justify-content: space-between;
align-items: center;
}

.title-with-jump h1 {
flex: 1;
}

.jump-link {
flex-shrink: 0;
font-size: 0.9rem;
}

@media (max-width: 500px) {
.title-with-jump {
flex-direction: column;
}
}
20 changes: 19 additions & 1 deletion templates/series.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,25 @@
{%- include "partials/home_banner.html" -%}
{% endif -%}

{{ macros_page_header::page_header(title=section.title) }}
{%- set show_jump = false -%}
{%- set setting_value = macros_settings::evaluate_setting_priority(setting="show_jump_to_posts", page=section) -%}
{%- if setting_value == "true" -%}
{%- set_global show_jump = true -%}
{%- elif setting_value != "false" -%}
{#- Default to true if the content is long and var is unset #}
{%- if section.content | length > 2000 -%}
{%- set_global show_jump = true -%}
{%- endif -%}
{%- endif -%}

{%- if show_jump -%}
<div class="title-with-jump bottom-divider">
<h1 class="title-container section-title">{{ section.title }}</h1>
<a href="#posts-list" class="jump-link">{{ macros_translate::translate(key="jump_to_posts", default="Jump to posts", language_strings=language_strings) }} ↓</a>
</div>
{%- else -%}
{{ macros_page_header::page_header(title=section.title) }}
{%- endif -%}

<section class="body">
{{ section.content | safe }}
Expand Down
5 changes: 5 additions & 0 deletions theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ show_date = true
# "both" - Show both the original date and the last updated date.
post_listing_date = "date"

# Show "Jump to posts" link next to series' title.
# By default, the link appears automatically when a series description exceeds 2000 characters.
# 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
# show_jump_to_posts = true

# Determines if indexes should be increasing (false) or decreasing (true) in series' posts list.
# It has only effect if the section uses indexes metadata (which is only the case for series as of now).
# Can be set at section levels, following the hierarchy: section > config. See: https://welpo.github.io/tabi/blog/mastering-tabi-settings/#settings-hierarchy
Expand Down

0 comments on commit ab95d5b

Please sign in to comment.