diff --git a/WebsiteGenerator/Generators/OverviewPageGenerator.swift b/WebsiteGenerator/Generators/OverviewPageGenerator.swift index d9fba95..4780891 100644 --- a/WebsiteGenerator/Generators/OverviewPageGenerator.swift +++ b/WebsiteGenerator/Generators/OverviewPageGenerator.swift @@ -10,12 +10,12 @@ struct OverviewPageGenerator { func generate( section: Element, - language: String, - backText: String?) { + language: String) { let path = section.localizedPath(for: language) let url = files.urlInOutputFolder(path) let metadata = section.localized(for: language) + let backLinkText = section.backLinkText(for: language) var content = [PageTemplate.Key : String]() content[.head] = factory.pageHead.generate(page: section, language: language) @@ -24,7 +24,7 @@ struct OverviewPageGenerator { sectionUrl: section.sectionUrl(for: language), languageButton: languageButton) content[.contentClass] = "overview" - content[.header] = makeHeader(metadata: metadata, language: language, backText: backText) + content[.header] = makeHeader(metadata: metadata, language: language, backText: backLinkText) content[.content] = makeContent(section: section, language: language) content[.footer] = section.customFooterContent() guard factory.page.generate(content, to: url) else { diff --git a/WebsiteGenerator/Generators/PageGenerator.swift b/WebsiteGenerator/Generators/PageGenerator.swift index 143f2d3..543a28e 100644 --- a/WebsiteGenerator/Generators/PageGenerator.swift +++ b/WebsiteGenerator/Generators/PageGenerator.swift @@ -16,7 +16,7 @@ struct PageGenerator { self.factory = factory } - func generate(page: Element, language: String, backText: String, nextPage: NavigationLink?, previousPage: NavigationLink?) { + func generate(page: Element, language: String, nextPage: NavigationLink?, previousPage: NavigationLink?) { guard !page.isExternalPage else { return } @@ -28,13 +28,14 @@ struct PageGenerator { #warning("Make prev and next navigation relative") let metadata = page.localized(for: language) let nextLanguage = page.nextLanguage(for: language) + var content = [PageTemplate.Key : String]() content[.head] = factory.pageHead.generate(page: page, language: language) let sectionUrl = page.sectionUrl(for: language) content[.topBar] = factory.topBar.generate(sectionUrl: sectionUrl, languageButton: nextLanguage) content[.contentClass] = "content" if !page.useCustomHeader { - content[.header] = makeHeader(page: page, metadata: metadata, language: language, backText: backText) + content[.header] = makeHeader(page: page, metadata: metadata, language: language) } let pageContent = makeContent(page: page, language: language, path: inputContentPath) content[.content] = pageContent ?? factory.placeholder @@ -59,7 +60,9 @@ struct PageGenerator { .generate(page: page, language: language, content: content) } - private func makeHeader(page: Element, metadata: Element.LocalizedMetadata, language: String, backText: String) -> String { + private func makeHeader(page: Element, metadata: Element.LocalizedMetadata, language: String) -> String { + let backText = page.backLinkText(for: language) + var content = [HeaderKey : String]() content[.backLink] = factory.makeBackLink(text: backText, language: language) if let suffix = metadata.titleSuffix { diff --git a/WebsiteGenerator/Generators/SiteGenerator.swift b/WebsiteGenerator/Generators/SiteGenerator.swift index 2d85f2a..6133cb6 100644 --- a/WebsiteGenerator/Generators/SiteGenerator.swift +++ b/WebsiteGenerator/Generators/SiteGenerator.swift @@ -27,18 +27,15 @@ struct SiteGenerator { element.requiredFiles.forEach(files.require) - let backLinkText = element.backLinkText(for: language) if !element.elements.isEmpty { overviewGenerator.generate( section: element, - language: language, - backText: backLinkText) + language: language) } else { #warning("Determine previous and next pages") pageGenerator.generate( page: element, language: language, - backText: backLinkText, nextPage: nil, previousPage: nil) }