diff --git a/_includes/topics.html b/_includes/topics.html index 45a7e6a..d32137f 100644 --- a/_includes/topics.html +++ b/_includes/topics.html @@ -1,5 +1,5 @@ \ No newline at end of file diff --git a/_plugins/fetch_posts.rb b/_plugins/fetch_posts.rb index c1d1d2d..cacceb5 100644 --- a/_plugins/fetch_posts.rb +++ b/_plugins/fetch_posts.rb @@ -40,28 +40,27 @@ class BeatrootNews < Jekyll::Generator # Main plugin action, called by Jekyll-core def generate(site) @site = site - site.data['topics'] = Set.new site.data['topics'] - count = 0 + # Topic Counter + site.data['topics'] = site.data['topics'].to_h {|topic| [topic, 0]} get_content.each do |article| page = make_page(article['attributes']['modules']) if page site.pages << page page['topics'].each do |topic| unless site.data['topics'].include? topic - site.data['topics'] << topic + site.data['topics'][topic] = 0 Jekyll.logger.warn "News:", "New Topic #{topic}" end end - count+=1 + site.data['topics'][page['topics'].first] += 1 end end - site.data['topics'].each do |topic| + site.data['topics'].each do |topic, count| @site.pages << make_topic_page(topic) end - site.data['topics'] = site.data['topics'].to_a.sort - Jekyll.logger.info "News:", "Generated #{count} pages" + Jekyll.logger.info "News:", "Generated #{site.data['topics'].values.sum} pages" end private diff --git a/index.html b/index.html index e2ebd33..f8a0e82 100644 --- a/index.html +++ b/index.html @@ -7,23 +7,17 @@ layout: default

{{page.title}}

-{% for topic in site.data.topics %} -{% assign post_count = 0 %} -{% capture h %} - +{% for T in site.data.topics %} +{% assign post_count = T[1] %} +{% if post_count > 0 %}
-

{{topic | capitalize}}

+

{{T[0] | capitalize}}

{% for post in site.pages %} - {% if post.topics and post.topics.first == topic %} + {% if post.topics and post.topics.first == T[0] %} {% include_cached story.html story=post heading_level=3%} - {% assign post_count = post_count | plus: 1 %} {% endif %} {% endfor %}
-{% endcapture %} - -{% if post_count > 0 %} -{{h}} {% endif %} {% endfor %} diff --git a/settings.html b/settings.html index 687c8c3..b26527f 100644 --- a/settings.html +++ b/settings.html @@ -20,11 +20,11 @@ noindex: true

Hide These Topics

Topics are only hidden on the home screen - {% for topic in site.data.topics %} + {% for T in site.data.topics %} -