Sha256: 2180e869ac6504cddbd93aa78102183bfed3052048049a429360fd0add1d093e

Contents?: true

Size: 1.29 KB

Versions: 5

Compression:

Stored size: 1.29 KB

Contents

# Frozen-string-literal: true
# Encoding: utf-8

module Jekyll
  class LanguageCollectionReader < CollectionReader
    def read
      site.collections.each do |_, collection|
        next if SPECIAL_COLLECTIONS.include?(collection.label)
        collection.read
        collection.docs = collection.docs.flat_map do |document|
          ldocuments = []
          ldocument = LanguageDocument.new(document.path, { site: @site, collection: collection })
          ldocument.read

          if ldocument.languages
            for language in ldocument.languages do
              if ldocument.language == language
                ldocuments << ldocument
              elsif ldocument.language.nil?
                ldocument.data['language'] = language
                ldocuments << ldocument
              else
                ldocument2 = LanguageDocument.new(document.path, { site: @site, collection: collection })
                ldocument2.read
                ldocument2.data['language'] = language
                ldocuments << ldocument2
              end
            end
          elsif ldocument.language
            ldocuments << ldocument
          else
            # no languages -> do not add extended Page
            ldocuments << document
          end
          ldocuments
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jekyll-language-plugin-1.3.5 lib/jekyll/readers/language_collection_reader.rb
jekyll-language-plugin-1.3.4 lib/jekyll/readers/language_collection_reader.rb
jekyll-language-plugin-1.3.3 lib/jekyll/readers/language_collection_reader.rb
jekyll-language-plugin-1.3.2 lib/jekyll/readers/language_collection_reader.rb
jekyll-language-plugin-1.3.1 lib/jekyll/readers/language_collection_reader.rb