summaryrefslogtreecommitdiff
path: root/_includes/tags.html
diff options
context:
space:
mode:
authorKarl Hallsby <karl@hallsby.com>2020-09-27 17:45:13 -0500
committerKarl Hallsby <karl@hallsby.com>2020-09-27 17:45:13 -0500
commitc6bf5f7c895287d2028f6024265913b59784a154 (patch)
tree3a298df17d9472a679411dd81ea00a1239652477 /_includes/tags.html
parent50dafcddc0392b99b228824274b1b97d0e72e423 (diff)
Bring all of jekyll-text-theme _includes into site
Diffstat (limited to '_includes/tags.html')
-rw-r--r--_includes/tags.html52
1 files changed, 52 insertions, 0 deletions
diff --git a/_includes/tags.html b/_includes/tags.html
new file mode 100644
index 0000000..424804c
--- /dev/null
+++ b/_includes/tags.html
@@ -0,0 +1,52 @@
+{%- assign _tag_max_size = 1 -%}
+{%- assign _tag_min_size = 1 -%}
+{%- assign _tag_cur_size = 1 -%}
+{%- assign _tags = site.tags | sort -%}
+{%- for _tag in _tags -%}
+ {%- assign _tag_cur_size = _tag[1].size -%}
+ {%- if _tag_cur_size > _tag_max_size -%}
+ {%- assign _tag_max_size = _tag_cur_size -%}
+ {%- endif -%}
+ {%- if _tag_cur_size < _tag_min_size -%}
+ {%- assign _tag_min_size = _tag_cur_size -%}
+ {%- endif -%}
+{%- endfor -%}
+{%- assign _tag_gap_size = _tag_max_size | minus: _tag_min_size | plus: 1 | divided_by: 4 -%}
+{%- if _tag_gap_size < 1 -%}
+ {%- assign _tag_gap_size = 1 -%}
+{%- endif -%}
+<div class="site-tags js-tags">
+ <ul class="menu">
+ <li>
+ <button type="button" class="button button--secondary button--pill tag-button tag-button--all" data-encode="">
+ Show All<div class="tag-button__count">{{ site.posts | size }}</div>
+ </button>
+ </li>
+ {%- for _tag in _tags -%}
+ {%- assign _tag_cur_size = _tag[1].size -%}
+ {%- assign _tag_min_1 = _tag_min_size -%}
+ {%- assign _tag_max_1 = _tag_min_1 | plus: _tag_gap_size -%}
+ {%- assign _tag_min_2 = _tag_max_1 -%}
+ {%- assign _tag_max_2 = _tag_min_2 | plus: _tag_gap_size -%}
+ {%- assign _tag_min_3 = _tag_max_2 -%}
+ {%- assign _tag_max_3 = _tag_min_3 | plus: _tag_gap_size -%}
+ {%- assign _tag_min_4 = _tag_max_3 -%}
+ {%- assign _tag_max_4 = _tag_min_4 | plus: _tag_gap_size -%}
+ {%- if _tag_cur_size >= _tag_min_1 and _tag_cur_size < _tag_max_1 -%}
+ {%- assign _c_index = 1 -%}
+ {%- elsif _tag_cur_size >= _tag_min_2 and _tag_cur_size < _tag_max_2 -%}
+ {%- assign _c_index = 2 -%}
+ {%- elsif _tag_cur_size >= _tag_min_3 and _tag_cur_size < _tag_max_3 -%}
+ {%- assign _c_index = 3 -%}
+ {%- elsif _tag_cur_size >= _tag_min_4 and _tag_cur_size < _tag_max_4 -%}
+ {%- assign _c_index = 4 -%}
+ {%- else -%}
+ {%- assign _c_index = 4 -%}
+ {%- endif -%}
+ <li><button type="button" class="button button--pill tag-button tag-button-{{ _c_index }}" data-encode="{{ _tag[0] | strip | url_encode }}">
+ <span>{{ _tag[0] | strip }}</span><div class="tag-button__count">{{ _tag[1].size }}</div>
+ </button>
+ </li>
+ {%- endfor -%}
+ </ul>
+</div>