class Jekyll::ArchivesV2::Archive

def date

Returns a Date.

Produce a date object if a date-based archive
def date
  return unless @title.is_a?(Hash)
  @date ||= begin
    args = @title.values.map(&:to_i)
    Date.new(*args)
  end
end

def initialize(site, title, type, collection_name, documents)

documents - The array of documents that belong in this archive.
collection_name - The name of the collection.
type - The type of archive. Can be one of "year", "month", "day", "category", or "tag"
e.g. { :year => 2014, :month => 08 } or "my-category" or "my-tag".
title - The name of the tag/category or a Hash of the year/month/day in case of date.
site - The Site object.

Initialize a new Archive page
def initialize(site, title, type, collection_name, documents)
  @site   = site
  @documents  = documents
  @type   = type
  @title  = title
  @collection_name = collection_name
  @config = site.config["jekyll-archives"][collection_name]
  @slug   = slugify_string_title
  # Use ".html" for file extension and url for path
  @ext  = File.extname(relative_path)
  @path = relative_path
  @name = File.basename(relative_path, @ext)
  @data = {
    "layout" => layout,
  }
  @content = ""
end

def inspect

Returns the object as a debug String.
def inspect
  "#<Jekyll:Archive @type=#{@type} @title=#{@title} @data=#{@data.inspect}>"
end

def layout

Returns the layout as a String

The layout to use for rendering
def layout
  @config.dig("layouts", type) || @config["layout"]
end

def permalink

def permalink
  data&.is_a?(Hash) && data["permalink"]
end

def relative_path

Returns the destination relative path String.

Obtain the write path relative to the destination directory
def relative_path
  @relative_path ||= begin
    path = URL.unescape_path(url).gsub(%r!^/!, "")
    path = File.join(path, "index.html") if url.end_with?("/")
    path
  end
end

def slugify_string_title

downcasing it.
Note: mode other than those expected by Jekyll returns the given string after

Generate slug if @title attribute is a string.
def slugify_string_title
  return unless title.is_a?(String)
  Utils.slugify(title, :mode => @config["slug_mode"])
end

def template

Returns the template String.

The template of the permalink.
def template
  @config.dig("permalinks", type)
end

def title

date-based archives.
Returns a String (for tag and category archives) and nil for

Produce a title object suitable for Liquid based on type of archive.
def title
  @title if @title.is_a? String
end

def to_liquid

The Liquid representation of this page.
def to_liquid
  @to_liquid ||= Jekyll::ArchivesV2::PageDrop.new(self)
end

def url

Returns the String url.

The generated relative url of this page. e.g. /about.html.
def url
  @url ||= URL.new(
    :template     => template,
    :placeholders => url_placeholders,
    :permalink    => nil
  ).to_s
rescue ArgumentError
  raise ArgumentError, "Template \"#{template}\" provided is invalid."
end

def url_placeholders

desired placeholder replacements. For details see "url.rb".
Returns a hash of URL placeholder names (as symbols) mapping to the
def url_placeholders
  if @title.is_a? Hash
    @title.merge(:collection => @collection_name, :type => @type)
  else
    { :collection => @collection_name, :name => @slug, :type => @type }
  end
end