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 {
return nil
}
let state: PageState = log.cast(metadata.state, "state", source: source)
guard state != .ignored else {
return nil
}
var isValid = true
@ -248,7 +252,7 @@ struct Element {
self.topBarTitle = log.unused(metadata.topBarTitle, "topBarTitle", 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.state = log.cast(metadata.state, "state", source: source)
self.state = state
self.sortIndex = metadata.sortIndex
// TODO: Propagate external files from the parent if subpath matches?
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.
*/
case hidden
/**
Completely ignore the element.
*/
case ignored
}
extension PageState {
@ -23,7 +28,7 @@ extension PageState {
switch self {
case .standard, .draft:
return true
case .hidden:
case .hidden, .ignored:
return false
}
}
@ -32,9 +37,7 @@ extension PageState {
switch self {
case .standard:
return true
case .draft:
return false
case .hidden:
case .draft, .hidden, .ignored:
return false
}
}
@ -47,7 +50,7 @@ extension PageState: StringProperty {
}
static var castFailureReason: String {
"Page state must be 'standard', 'draft' or 'hidden'"
"Page state must be 'standard', 'draft', 'hidden', or 'ignored'"
}
}