Add ignored state for pages

This commit is contained in:
Christoph Hagen 2023-08-16 12:11:59 +02:00
parent 5cb0ef6b87
commit d1f7738f09
2 changed files with 13 additions and 6 deletions

View File

@ -240,6 +240,10 @@ struct Element {
guard let metadata = GenericMetadata(source: source, log: log) else { guard let metadata = GenericMetadata(source: source, log: log) else {
return nil return nil
} }
let state: PageState = log.cast(metadata.state, "state", source: source)
guard state != .ignored else {
return nil
}
var isValid = true var isValid = true
@ -248,7 +252,7 @@ struct Element {
self.topBarTitle = log.unused(metadata.topBarTitle, "topBarTitle", source: source) self.topBarTitle = log.unused(metadata.topBarTitle, "topBarTitle", source: source)
self.date = metadata.date.unwrapped { log.cast($0, "date", source: source) } self.date = metadata.date.unwrapped { log.cast($0, "date", source: source) }
self.endDate = metadata.endDate.unwrapped { log.cast($0, "endDate", source: source) } self.endDate = metadata.endDate.unwrapped { log.cast($0, "endDate", source: source) }
self.state = log.cast(metadata.state, "state", source: source) self.state = state
self.sortIndex = metadata.sortIndex self.sortIndex = metadata.sortIndex
// TODO: Propagate external files from the parent if subpath matches? // TODO: Propagate external files from the parent if subpath matches?
self.externalFiles = Element.rootPaths(for: metadata.externalFiles, path: path) self.externalFiles = Element.rootPaths(for: metadata.externalFiles, path: path)

View File

@ -15,6 +15,11 @@ enum PageState: String {
Generate the page, but don't include it in overviews of the parent. Generate the page, but don't include it in overviews of the parent.
*/ */
case hidden case hidden
/**
Completely ignore the element.
*/
case ignored
} }
extension PageState { extension PageState {
@ -23,7 +28,7 @@ extension PageState {
switch self { switch self {
case .standard, .draft: case .standard, .draft:
return true return true
case .hidden: case .hidden, .ignored:
return false return false
} }
} }
@ -32,9 +37,7 @@ extension PageState {
switch self { switch self {
case .standard: case .standard:
return true return true
case .draft: case .draft, .hidden, .ignored:
return false
case .hidden:
return false return false
} }
} }
@ -47,7 +50,7 @@ extension PageState: StringProperty {
} }
static var castFailureReason: String { static var castFailureReason: String {
"Page state must be 'standard', 'draft' or 'hidden'" "Page state must be 'standard', 'draft', 'hidden', or 'ignored'"
} }
} }