CHGenerator/Sources/Generator/Content/PageState.swift
2023-08-16 12:11:59 +02:00

61 lines
1.1 KiB
Swift

import Foundation
enum PageState: String {
/**
Generate the page, and show it in overviews of the parent.
*/
case standard
/**
Generate the page, but don't provide links in overviews.
*/
case draft
/**
Generate the page, but don't include it in overviews of the parent.
*/
case hidden
/**
Completely ignore the element.
*/
case ignored
}
extension PageState {
var isShownInOverview: Bool {
switch self {
case .standard, .draft:
return true
case .hidden, .ignored:
return false
}
}
var hasThumbnailLink: Bool {
switch self {
case .standard:
return true
case .draft, .hidden, .ignored:
return false
}
}
}
extension PageState: StringProperty {
init?(_ value: String) {
self.init(rawValue: value)
}
static var castFailureReason: String {
"Page state must be 'standard', 'draft', 'hidden', or 'ignored'"
}
}
extension PageState: DefaultValueProvider {
static var defaultValue: PageState { .standard }
}