2022-01-16 01:04:47 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-01-10 22:14:58 +01:00
|
|
|
module ApplicationHelper::TitleMethods
|
|
|
|
include MarkdownHelper
|
|
|
|
|
2022-01-16 14:13:01 +01:00
|
|
|
def generate_title(name, junction = nil, content = nil, possessive = false)
|
|
|
|
if possessive
|
2022-01-16 01:04:47 +01:00
|
|
|
name = if name[-1].downcase == "s"
|
|
|
|
"#{name}'"
|
|
|
|
else
|
|
|
|
"#{name}'s"
|
|
|
|
end
|
2022-01-10 22:14:58 +01:00
|
|
|
end
|
|
|
|
|
2022-01-16 01:04:47 +01:00
|
|
|
list = [name, junction].compact
|
2022-01-10 22:14:58 +01:00
|
|
|
|
|
|
|
unless content.nil?
|
|
|
|
content = strip_markdown(content)
|
2022-01-16 01:04:47 +01:00
|
|
|
content = "#{content[0..42]}…" if content.length > 45
|
2022-01-10 22:14:58 +01:00
|
|
|
list.push content
|
|
|
|
end
|
2022-01-16 01:04:47 +01:00
|
|
|
list.push "|", APP_CONFIG["site_name"]
|
2022-01-10 22:14:58 +01:00
|
|
|
|
|
|
|
list.join " "
|
|
|
|
end
|
2022-01-16 01:04:47 +01:00
|
|
|
end
|