Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cloudtag broken in Jekyll >= 4.1.0 #29

Open
dieghernan opened this issue Jun 18, 2023 Discussed in #28 · 4 comments
Open

cloudtag broken in Jekyll >= 4.1.0 #29

dieghernan opened this issue Jun 18, 2023 Discussed in #28 · 4 comments

Comments

@dieghernan
Copy link
Owner

Discussed in #28

Originally posted by cargocultprogramming June 17, 2023
I'm playing around with vanilla version of chulapa (changed the skin etc. but nothing major), but the /tags page has issues for me. Seems there is never a tag.name assigned. If I add a print statement to the tag in cloudtag.html like this:

{% 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?

@dieghernan
Copy link
Owner Author

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).

See jekyll/jekyll#8214

@dieghernan dieghernan changed the title Cannot figure out cloudtag cloudtag broken in Jekyll >= 4.1.0 Jun 18, 2023
@dieghernan
Copy link
Owner Author

@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 jekyll/jekyll#8214 (comment)

@cargocultprogramming
Copy link

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.

@rykerwilliams
Copy link

rykerwilliams commented Apr 25, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants