initialize

in _plugins/yearly_archive_plugin.rb [57:107]


    def initialize(site, dir, year, month, posts)
      @site = site
      @dir = dir
      @year = year
      @month = month
      @archive_dir_name = 'news/%04d' % [year]
      @date = Date.new(@year)
      @layout =  site.config['yearly_archive'] && site.config['yearly_archive']['layout'] || 'default'
      @months = posts.map{|p| Date.new(@year, p.date.month, 1) }.uniq
      self.ext = '.html'
      self.basename = 'index'
      self.content = <<-EOS
      {% for year in site.years %}
      {% assign y = year.first.first.date | date: '%Y' %}
      {% if y == '#{year}' %}
      <div class="l-first">
          {% for month in year %}
              {% assign m = month.first.date | date: '%m' %}
              <div  class="l-full">
                  <h1>All News for {{ month.first.date | date: "%B %Y" }}</h1>
                  <p>This section contains all news items published in <a href="{{site.baseurl}}/news/{{y}}/{{m}}">{{ month.first.date | date: "%B %Y" }}</a>.</p>
              </div>
              {% for post in month %}
                  <div class="l-full">
                      <h3 id="{{ site.baseurl }}{{post.url}}">{{post.title}}</h3>
                      <small>{{post.date | date_to_string}}</small>
                      <p>{{ post.content | markdownify | strip_html | truncatewords:25 }}
                      <a href="{{ site.baseurl }}{{post.url}}">more</a></li></p>
                  </div>
              {% endfor %}
              <hr>
              <div class="l-first"></div>
          {% endfor %}
      </div>
      {% endif %}
      {% endfor %}


      EOS
      self.data = {
          'layout' => @layout,
          'type' => 'archive',
          'title' => "Yearly archive for #{@year}",
          'months' => @months,
          'posts' => posts,
          'url' => File.join('/',
                     YearlyArchiveUtil.archive_base(site),
                     @archive_dir_name, 'index.html')
      }
    end