import Foundation class Item: ObservableObject, Identifiable { unowned let content: Content /// A dummy property to force views to update when properties change @Published private var changeToggle = false @Published var id: String init(content: Content, id: String) { self.content = content self.id = id } func didChange() { changeToggle.toggle() } func makeCleanAbsolutePath(_ path: String) -> String { "/" + makeCleanRelativePath(path) } func makeCleanRelativePath(_ path: String) -> String { path.components(separatedBy: "/").filter { !$0.isEmpty }.joined(separator: "/") } func title(in language: ContentLanguage) -> String { fatalError() } func absoluteUrl(in language: ContentLanguage) -> String { fatalError() } var itemType: ItemType { fatalError() } } extension Item: Equatable { static func == (lhs: Item, rhs: Item) -> Bool { lhs.id == rhs.id } } extension Item: Hashable { func hash(into hasher: inout Hasher) { hasher.combine(id) } } extension Item: Comparable { static func < (lhs: Item, rhs: Item) -> Bool { lhs.id < rhs.id } }