Open dieghernan opened 1 year ago
This is happening in Jekyll >=4.1.0 due a change on behaviour (maybe we were leveraging on a bug for creating the cloud tag).
@cargocultprogramming I just see as a solution either to downgrade to Jekyll 4.0.1 or less or try the solution based on plugins on https://github.com/jekyll/jekyll/issues/8214#issuecomment-636309479
Alright - solved this for me along the lines of the jekyll discussion linked above.
I added a custom filter like this:
module Jekyll
module TagFilters
def count_by_item(input)
input = input.is_a?(String) ? input.split(',') : input
counts = Hash.new(0)
input.flatten.each do |name|
name = name.strip
counts[name] += 1
end
sorted_counts = counts.sort_by { |tag, count| -count }
sorted_counts.to_h
end
end
end
Liquid::Template.register_filter(Jekyll::TagFilters)
Then in jekyll you can
{% assign tag_count = alldocs | map: 'tags' | count_by_item %}
Then you can loop over tag_count as now over grouptag
and replace tag.name
with tag[0]
and tag.size
with tag[1]
and it's all there.
EDIT. Kept hacking it and I figured it out. I think i'm squared now.
Mainly didn't understand the jekyll I needed to put in my page and what to do.
For anyone that finds this, I went to the main chulapa repo and looked at the cloudtag.html file and used that in conjunction with the comment from @cargocultprogramming to make a functioning tags page.
Thanks!
Discussed in https://github.com/dieghernan/chulapa/discussions/28
{% assign grouptag = alldocs | map: 'tags' | join: ',' | split: ',' | group_by: tag | sort: 'size' | reverse %} {%- for tag in grouptag -%} {{ tag }} {%- if forloop.first -%} {%- assign sizemax = tag.size -%} {%- elsif forloop.last -%} {% assign mid = tag.size | plus: sizemax | divided_by: 2 %} {%- endif -%} {%- endfor -%}
I get the following:{"name"=>"", "items"=>["starter", "syntax", "kramdown", "starter", "syntax", "markdown", "skin", "bootstrap", "current-theme", "header-hero", "image", "demo", "landscape", "trips", "downtown", "project-links", "wikipedia", "image", "example", "demo", "layout", "guest-author", "image", "landscape", "trips", "downtown", "edinburgh", "kramdown", "bootstrap", "wikipedia", "demo", "image", "urban art", "street", "downtown", "image", "random", "manuscript", "markdown", "exciting-stuff", "wikipedia", "manuscript", "random", "diary", "school", "manuscript", "random", "exciting-stuff", "wikipedia", "pirates", "random", "wikipedia", "random", "exciting-stuff"], "size"=>54}
The rest of the page shows tags.size correctly, but nothing else obviously since tag.name is empty. Seems something goes wrong in the grouptag assignment but I cannot figure it out. Any ideas?