import Foundation final class Page: ObservableObject { /** The unique id of the entry */ @Published var id: String @Published var isDraft: Bool @Published var createdDate: Date @Published var startDate: Date @Published var hasEndDate: Bool @Published var endDate: Date @Published var german: LocalizedPage @Published var english: LocalizedPage @Published var tags: [Tag] /** Additional images required by the element. These images are specified as: `source_name destination_name width (height)`. */ @Published var images: Set = [] init(id: String, isDraft: Bool, createdDate: Date, startDate: Date, endDate: Date?, german: LocalizedPage, english: LocalizedPage, tags: [Tag]) { self.id = id self.isDraft = isDraft self.createdDate = createdDate self.startDate = startDate self.hasEndDate = endDate != nil self.endDate = endDate ?? startDate self.german = german self.english = english self.tags = tags } func localized(in language: ContentLanguage) -> LocalizedPage { switch language { case .german: return german case .english: return english } } } extension Page: Identifiable { } extension Page: Equatable { static func == (lhs: Page, rhs: Page) -> Bool { lhs.id == rhs.id } } extension Page: Hashable { func hash(into hasher: inout Hasher) { hasher.combine(id) } }