Sha256: 2388f2ba058ccc332173d1c4ba116aa54c0a40a80504016c2c22f26618727077

Contents?: true

Size: 881 Bytes

Versions: 4

Compression:

Stored size: 881 Bytes

Contents

module Jekyll
  class LanguagePostReader < PostReader
    alias_method :read_content_orig, :read_content

    def read_content(dir, magic_dir, matcher)
      read_content_orig(dir, magic_dir, matcher).flat_map do |document|
        ldocument = LanguageDocument.new(document.path, { site: @site, collection: @site.posts })
        ldocument.read

        languages = ldocument.languages.is_a?(Enumerable) ? ldocument.languages : []
        if ldocument.language && !languages.include?(ldocument.language)
          languages.push(ldocument.language)
        end

        if languages.size == 0
          return [document]
        end

        languages.map do |language|
          ldocument2 = LanguageDocument.new(document.path, { site: @site, collection: @site.posts })
          ldocument2.data['language'] = language
          ldocument2
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jekyll-language-plugin-1.1.3 lib/jekyll/readers/language_post_reader.rb
jekyll-language-plugin-1.1.2 lib/jekyll/readers/language_post_reader.rb
jekyll-language-plugin-1.1.1 lib/jekyll/readers/language_post_reader.rb
jekyll-language-plugin-1.1.0 lib/jekyll/readers/language_post_reader.rb