import Foundation final class Page: ObservableObject { /** The unique id of the entry */ @Published var id: String @Published var isDraft: Bool @Published var metadata: [LocalizedPage] /** All files which may occur in content but is stored externally. Missing files which would otherwise produce a warning are ignored when included here. - Note: This property defaults to an empty set. */ @Published var externalFiles: Set = [] /** Specifies additional files which should be copied to the destination when generating the content. - Note: This property defaults to an empty set. */ @Published var requiredFiles: Set = [] /** 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, metadata: [LocalizedPage], externalFiles: Set = [], requiredFiles: Set = [], images: Set = []) { self.id = id self.isDraft = isDraft self.metadata = metadata self.externalFiles = externalFiles self.requiredFiles = requiredFiles self.images = images } func metadata(for language: ContentLanguage) -> LocalizedPage? { metadata.first { $0.language == language } } } struct LocalizedPage { let language: ContentLanguage /** The string to use when creating the url for the page. Defaults to ``id`` if unset. */ var urlString: String? /** The headline to use when showing the entry on it's own page */ var headline: String } 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) } }