Skip to content

Instantly share code, notes, and snippets.

@madhur
Forked from vilcans/gist:856414
Created March 5, 2011 15:03
Show Gist options
  • Save madhur/856416 to your computer and use it in GitHub Desktop.
Save madhur/856416 to your computer and use it in GitHub Desktop.

This is the code I use for the tag cloud at www.librador.com:

{% for tag in site.tags %}
  {% assign t = tag.first %}
  {% assign posts = tag.last %}
  <a class="tag tag{{ posts | size }}" href="/tags/#tag-{{ t | to_id }}">{{ t }}</a>
{% endfor %}

It expects there to be a CSS class called tag and several ones called tag1, tag2, tag3 etc, where the number is the number of posts with that tag. Here's my version:

.tag { font-size: 280%; }
.tag1 { font-size: 80%; }
.tag2 { font-size: 90%; }
.tag3 { font-size: 100%; }
.tag4 { font-size: 110%; }
.tag5 { font-size: 120%; }
.tag6 { font-size: 130%; }
.tag7 { font-size: 140%; }
.tag8 { font-size: 150%; }
.tag9 { font-size: 160%; }
.tag10 { font-size: 170%; }
.tag11 { font-size: 180%; }
.tag12 { font-size: 190%; }
.tag13 { font-size: 200%; }
.tag14 { font-size: 210%; }
.tag15 { font-size: 220%; }
.tag16 { font-size: 230%; }
.tag17 { font-size: 240%; }
.tag18 { font-size: 250%; }
.tag19 { font-size: 260%; }
.tag20 { font-size: 270%; }

Pretty primitive, but it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment