diff --git a/app/repos/tag_repo.rb b/app/repos/tag_repo.rb index ff277c8..a0a5f6f 100644 --- a/app/repos/tag_repo.rb +++ b/app/repos/tag_repo.rb @@ -8,6 +8,7 @@ module Adamantium def list tags .order(Sequel.function(:lower, :label)) + .combine(:posts) .to_a end end diff --git a/app/templates/tags/index.html.slim b/app/templates/tags/index.html.slim index 913d482..8ce83fe 100644 --- a/app/templates/tags/index.html.slim +++ b/app/templates/tags/index.html.slim @@ -3,13 +3,13 @@ div class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:text-gray-200 columns-2" h1 Tags - - tag_groups.each do |group, tags| + - tag_groups.each do |tags| div class="break-inside-avoid-column" - h3 class="border-b-2" class="text-xl mt-6 mb-2 font-bold text-gray-800 dark:text-gray-200" = group.upcase + h3 class="border-b-2" class="text-xl mt-6 mb-2 font-bold text-gray-800 dark:text-gray-200" = tags[:group].upcase - - tags.each do |post_tag| + - tags[:tags].each do |post_tag| div - a class="p-category no-underline rounded p-1 mr-1 u-url text-gray-600 dark:text-indigo-400 hover:text-gray-900" href="/tagged/#{post_tag.slug}" - = post_tag.label + a class="p-category no-underline rounded p-1 mr-1 u-url text-gray-600 dark:text-indigo-400 hover:text-indigo-200" href="/tagged/#{post_tag[:tag].slug}" + = "#{post_tag[:tag].label} (#{post_tag[:count]})" div class="max-w-screen-md mx-auto border-t border-solid border-gray-200 dark:border-gray-600" diff --git a/app/views/tags/index.rb b/app/views/tags/index.rb index d5fa39e..fccc9d1 100644 --- a/app/views/tags/index.rb +++ b/app/views/tags/index.rb @@ -12,6 +12,7 @@ module Adamantium /[a-z]/.match?(grouper) ? grouper : "#" } .sort + .map { |group, tags| {group: group, tags: tags.map {|tag| {tag: tag, count: tag.posts.count} }} } end end end