consolidate tags, hide date

This commit is contained in:
Christoph Hagen
2025-01-05 12:19:32 +01:00
parent 93e642c3c9
commit 5ac5a7b000
26 changed files with 284 additions and 129 deletions

View File

@@ -17,6 +17,9 @@ final class Page: Item {
@Published
var createdDate: Date
@Published
var hideDate: Bool
@Published
var startDate: Date
@@ -46,6 +49,7 @@ final class Page: Item {
externalLink: String?,
isDraft: Bool,
createdDate: Date,
hideDate: Bool,
startDate: Date,
endDate: Date?,
german: LocalizedPage,
@@ -55,6 +59,7 @@ final class Page: Item {
self.externalLink = externalLink
self.isDraft = isDraft
self.createdDate = createdDate
self.hideDate = hideDate
self.startDate = startDate
self.hasEndDate = endDate != nil
self.endDate = endDate ?? startDate
@@ -86,6 +91,34 @@ final class Page: Item {
externalLink != nil
}
// MARK: Tags
/**
Check if a tag is associated with this page
*/
func contains(_ tag: Tag) -> Bool {
tags.contains(tag)
}
func toggle(_ tag: Tag) {
guard let index = tags.firstIndex(of: tag) else {
tags.append(tag)
return
}
tags.remove(at: index)
}
func remove(_ tag: Tag) {
tags.remove(tag)
}
func associate(_ tag: Tag) {
guard !tags.contains(tag) else {
return
}
tags.append(tag)
}
// MARK: Paths
override func absoluteUrl(in language: ContentLanguage) -> String {