module Jekyll::Utils

def add_permalink_suffix(template, permalink_style)

Returns the updated permalink template

# => "/:basename"
add_permalink_suffix("/:basename", "/:year/:month/:title")

# => "/:basename/"
add_permalink_suffix("/:basename", "/:year/:month/:title/")

# => "/:basename:output_ext"
add_permalink_suffix("/:basename", :date)

# => "/:basename/"
add_permalink_suffix("/:basename", :pretty)
Examples:

template. Otherwise, template will be returned without modification.
":output_ext" (or is :none, :date, or :ordinal) then so will the returned
then so will the returned template. If permalink_style has a trailing
trailing slash (or is :pretty, which indirectly has a trailing slash),
specified in permalink_style. For example, if permalink_style contains a
The returned permalink template will use the same ending style as

permalink_style - permalink style, either built-in or custom
template - permalink template without trailing slash or file extension

permalink style.
Add an appropriate suffix to template so that it matches the specified
def add_permalink_suffix(template, permalink_style)
  template = template.dup
  case permalink_style
  when :pretty
    template << "/"
  when :date, :ordinal, :none
    template << ":output_ext"
  else
    template << "/" if permalink_style.to_s.end_with?("/")
    template << ":output_ext" if permalink_style.to_s.end_with?(":output_ext")
  end
  template
end