From d1f7738f099a06a74588a625b6a6056c9ba39dfe Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Wed, 16 Aug 2023 12:11:59 +0200 Subject: [PATCH] Add ignored state for pages --- Sources/Generator/Content/Element.swift | 6 +++++- Sources/Generator/Content/PageState.swift | 13 ++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Sources/Generator/Content/Element.swift b/Sources/Generator/Content/Element.swift index 2d7407d..7314dab 100644 --- a/Sources/Generator/Content/Element.swift +++ b/Sources/Generator/Content/Element.swift @@ -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) diff --git a/Sources/Generator/Content/PageState.swift b/Sources/Generator/Content/PageState.swift index b0a5faa..009dd47 100644 --- a/Sources/Generator/Content/PageState.swift +++ b/Sources/Generator/Content/PageState.swift @@ -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'" } }