Sha256: 0e2eb526fe488e3f8b9270e695ea4652d9dcd9e440569e0960bcefed5553abc2

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Jekyll
  module Podcast
    module ContributorPageGenerator
      # Adds posts to each contributor page on the site
      class Generator < Jekyll::Generator
        def generate(site)
          @site = site
          collect_contributor_posts
          @site.documents.each do |doc|
            next unless doc.type == contributors_alias.to_sym

            doc.data['posts'] = @contributor_posts[doc.data['title']]
          end
        end

        private

        def collect_contributor_posts
          @contributor_posts = {}
          @site.posts.docs.each do |post|
            next unless post.data[contributors_alias]

            post.data[contributors_alias].each do |contributor|
              @contributor_posts[contributor] ||= []
              @contributor_posts[contributor].push(post)
            end
          end
        end

        def contributors_alias
          @site.config['podcast']['contributors_alias'] || 'contributors'
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jekyll-podcast-0.9.1 lib/jekyll/podcast/contributor_page_generator.rb
jekyll-podcast-0.9.0 lib/jekyll/podcast/contributor_page_generator.rb