Generate placeholders from element info, not root

Remove unused variable
This commit is contained in:
Christoph Hagen 2022-08-29 15:29:29 +02:00
parent 160d0df9c4
commit a98e134004
2 changed files with 7 additions and 9 deletions

View File

@ -36,7 +36,7 @@ struct PageGenerator {
if !page.useCustomHeader { if !page.useCustomHeader {
content[.header] = makeHeader(page: page, metadata: metadata, language: language) content[.header] = makeHeader(page: page, metadata: metadata, language: language)
} }
content[.content] = pageContent?.content ?? factory.placeholder content[.content] = pageContent?.content ?? factory.makePlaceholder(metadata: metadata)
content[.previousPageLinkText] = previousPage.unwrapped { factory.factory.html.makePrevText($0.text) } content[.previousPageLinkText] = previousPage.unwrapped { factory.factory.html.makePrevText($0.text) }
content[.previousPageUrl] = previousPage?.link content[.previousPageUrl] = previousPage?.link
content[.nextPageLinkText] = nextPage.unwrapped { factory.factory.html.makeNextText($0.text) } content[.nextPageLinkText] = nextPage.unwrapped { factory.factory.html.makeNextText($0.text) }

View File

@ -19,8 +19,6 @@ struct LocalizedSiteTemplate {
let overviewSection: OverviewSectionGenerator let overviewSection: OverviewSectionGenerator
let placeholder: String
private let fullDateFormatter: DateFormatter private let fullDateFormatter: DateFormatter
private let month: DateFormatter private let month: DateFormatter
@ -57,8 +55,6 @@ struct LocalizedSiteTemplate {
df3.locale = Locale(identifier: language) df3.locale = Locale(identifier: language)
self.day = df3 self.day = df3
let metadata = site.localized(for: language)
let sections = site.sortedItems.map { let sections = site.sortedItems.map {
PrefilledTopBarTemplate.SectionInfo( PrefilledTopBarTemplate.SectionInfo(
name: $0.title(for: language), name: $0.title(for: language),
@ -74,14 +70,16 @@ struct LocalizedSiteTemplate {
factory: factory) factory: factory)
self.overviewSection = OverviewSectionGenerator( self.overviewSection = OverviewSectionGenerator(
factory: factory) factory: factory)
self.placeholder = factory.placeholder.generate([
.title: metadata.placeholderTitle,
.text: metadata.placeholderText])
} }
// MARK: Content // MARK: Content
func makePlaceholder(metadata: Element.LocalizedMetadata) -> String {
factory.placeholder.generate([
.title: metadata.placeholderTitle,
.text: metadata.placeholderText])
}
func makeBackLink(text: String, language: String) -> String { func makeBackLink(text: String, language: String) -> String {
let content: [BackNavigationTemplate.Key : String] = [ let content: [BackNavigationTemplate.Key : String] = [
.text: text, .text: text,