CHGenerator/Sources/Generator/Content/PageState.swift

61 lines
1.1 KiB
Swift
Raw Normal View History

2022-08-19 18:05:06 +02:00
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.
*/
2022-08-29 13:34:10 +02:00
case hidden
2023-08-16 12:11:59 +02:00
/**
Completely ignore the element.
*/
case ignored
2022-08-19 18:05:06 +02:00
}
2022-08-26 22:29:32 +02:00
extension PageState {
var isShownInOverview: Bool {
switch self {
case .standard, .draft:
return true
2023-08-16 12:11:59 +02:00
case .hidden, .ignored:
2022-08-26 22:29:32 +02:00
return false
}
}
var hasThumbnailLink: Bool {
switch self {
case .standard:
return true
2023-08-16 12:11:59 +02:00
case .draft, .hidden, .ignored:
2022-08-26 22:29:32 +02:00
return false
}
}
}
extension PageState: StringProperty {
init?(_ value: String) {
self.init(rawValue: value)
}
static var castFailureReason: String {
2023-08-16 12:11:59 +02:00
"Page state must be 'standard', 'draft', 'hidden', or 'ignored'"
}
}
extension PageState: DefaultValueProvider {
static var defaultValue: PageState { .standard }
}