Add option to use custom header code
This commit is contained in:
parent
c8a70a3d42
commit
5ec0502eab
@ -20,6 +20,14 @@ extension Page {
|
||||
|
||||
let requiredFiles: [String]
|
||||
|
||||
/**
|
||||
Indicate that no header should be generated automatically.
|
||||
|
||||
This option assumes that custom header code is present in the page source files
|
||||
- Note: If not specified, this property defaults to `false`.
|
||||
*/
|
||||
let useCustomHeader: Bool
|
||||
|
||||
#warning("Add files for which errors are ignored when missing")
|
||||
}
|
||||
}
|
||||
@ -36,7 +44,8 @@ extension Page.Metadata: Metadata {
|
||||
isDraft: true,
|
||||
sortIndex: 0,
|
||||
languages: [.initial],
|
||||
requiredFiles: [])
|
||||
requiredFiles: [],
|
||||
useCustomHeader: false)
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,6 +63,7 @@ extension Page.Metadata: Codable {
|
||||
case sortIndex
|
||||
case languages
|
||||
case requiredFiles
|
||||
case useCustomHeader
|
||||
}
|
||||
|
||||
func encode(to encoder: Encoder) throws {
|
||||
@ -71,6 +81,9 @@ extension Page.Metadata: Codable {
|
||||
if !requiredFiles.isEmpty {
|
||||
try container.encode(requiredFiles, forKey: .requiredFiles)
|
||||
}
|
||||
if useCustomHeader {
|
||||
try container.encode(true, forKey: .useCustomHeader)
|
||||
}
|
||||
}
|
||||
|
||||
init(from decoder: Decoder) throws {
|
||||
@ -89,5 +102,6 @@ extension Page.Metadata: Codable {
|
||||
self.endDate = nil
|
||||
}
|
||||
self.requiredFiles = try container.decodeIfPresent([String].self, forKey: .requiredFiles) ?? []
|
||||
self.useCustomHeader = try container.decodeIfPresent(Bool.self, forKey: .useCustomHeader) ?? false
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,9 @@ struct PageGenerator {
|
||||
content[.head] = try makeHead(page: page, language: language)
|
||||
content[.topBar] = factory.topBar.generate(section: page.sectionId, languageButton: nextLanguage)
|
||||
content[.contentClass] = "content"
|
||||
content[.header] = makeHeader(page: page.metadata, metadata: metadata, language: language, backText: backText)
|
||||
if page.metadata.useCustomHeader {
|
||||
content[.header] = makeHeader(page: page.metadata, metadata: metadata, language: language, backText: backText)
|
||||
}
|
||||
content[.content] = try makeContent(page: page, language: language, url: inputContentUrl)
|
||||
content[.previousPageLinkText] = previousPage.unwrapped { factory.makePrevText($0.text) }
|
||||
content[.previousPageUrl] = previousPage?.link
|
||||
|
Loading…
Reference in New Issue
Block a user