CHGenerator/Sources/Generator/Content/PageState.swift
2022-12-01 14:50:26 +01:00

58 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
}
extension PageState {
var isShownInOverview: Bool {
switch self {
case .standard, .draft:
return true
case .hidden:
return false
}
}
var hasThumbnailLink: Bool {
switch self {
case .standard:
return true
case .draft:
return false
case .hidden:
return false
}
}
}
extension PageState: StringProperty {
init?(_ value: String) {
self.init(rawValue: value)
}
static var castFailureReason: String {
"Page state must be 'standard', 'draft' or 'hidden'"
}
}
extension PageState: DefaultValueProvider {
static var defaultValue: PageState { .standard }
}