Sha256: 74a2084c3cbdabe5041bc9f3bd6c992826fc3f5f4bf5a48d30e6ecb581ef5b5e

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

module Jekyll
  class LanguagePageReader < PageReader
    alias_method :read_orig, :read

    def read(files)
      read_orig(files).flat_map do |page|
        lpages = []
        #TODO: this is a bit hacky. It would be better to directly have access to @dir instance variable
        path = page.url_placeholders[:path]
        lpage = LanguagePage.new(@site, @site.source, path, page.name)
        if lpage.languages
          for language in lpage.languages do
            if lpage.language == language
              lpages << lpage
            elsif lpage.language.nil?
              lpage.data['language'] = language
              lpages << lpage
            else
              lpage2 = LanguagePage.new(@site, @site.source, path, page.name)
              lpage2.data['language'] = language
              lpages << lpage2
            end
          end
        elsif lpage.language
          lpages << lpage
        else
          # no languages -> do not add extended Page
          lpages << page
        end
        lpages
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jekyll-language-plugin-1.2.3 lib/jekyll/readers/language_page_reader.rb
jekyll-language-plugin-1.2.2 lib/jekyll/readers/language_page_reader.rb
jekyll-language-plugin-1.2.0 lib/jekyll/readers/language_page_reader.rb
jekyll-language-plugin-1.1.8 lib/jekyll/readers/language_page_reader.rb