// TODO: Move to settings? extension HeaderElement { static let swiperCssFileOrder = 41 static let defaultCssFileOrder = 42 static let audioPlayerCssOrder = 43 static let imageCompareCssOrder = 44 } enum HeaderElement { /// Order: 10-19 case icon(file: FileResource, size: Int, rel: String) /// Order: From 40-99, lower numbers appear first case css(file: FileResource, order: Int) /// Order: 20-29 case js(file: FileResource, defer: Bool) /// Order: 30-39 case jsModule(FileResource) case author(String) case title(String) case description(String) case ogTitle(String) case ogDescription(String) case ogImage(String) case ogUrl(String) case charset case viewport case robots case manifest(FileResource) case style(String) var order: Int { switch self { case .charset: 1 case .robots: 2 case .viewport: 3 case .manifest: 4 case .icon: 10 case .css(_, let order): order case .js: 20 case .jsModule: 30 case .author: 100 case .title: 101 case .description: 102 case .ogTitle: 103 case .ogDescription: 104 case .ogImage: 105 case .ogUrl: 106 case .style: 200 } } var requiredFile: FileResource? { switch self { case .icon(let file, _, _): return file case .css(let file, _): return file case .js(let file, _): return file case .jsModule(let file): return file case .manifest(let file): return file default: return nil } } } extension HeaderElement: Hashable { } extension HeaderElement: Comparable { static func < (lhs: HeaderElement, rhs: HeaderElement) -> Bool { lhs.order < rhs.order } } extension HeaderElement { var content: String { switch self { case .icon(let file, let size, let rel): return "" case .css(let file, _): return "" case .js(let file, let deferred): let deferText = deferred ? " defer" : "" return "" case .jsModule(let file): return "" case .author(let author): return "" case .title(let title): return "