Add title suffix, extract HTML elements

Fix header calls
This commit is contained in:
Christoph Hagen
2022-08-28 11:14:11 +02:00
parent 9c74f76650
commit 4036452d2c
8 changed files with 49 additions and 34 deletions

View File

@ -142,5 +142,20 @@ struct LocalizedSiteTemplate {
return fullDateFormatter.string(from: start)
.insert(" - \(day.string(from: end))", beforeLast: ",")
}
func makeHeaderContent(page: Element, metadata: Element.LocalizedMetadata, language: String) -> [HeaderKey : String] {
let backText = page.backLinkText(for: language)
var content = [HeaderKey : String]()
content[.backLink] = makeBackLink(text: backText, language: language)
if let suffix = metadata.titleSuffix {
content[.title] = factory.html.make(title: metadata.title, suffix: suffix)
} else {
content[.title] = metadata.title
}
content[.subtitle] = metadata.subtitle
content[.date] = makeDateString(start: page.date, end: page.endDate)
return content
}
}