Unified detail views, model

This commit is contained in:
Christoph Hagen
2024-12-16 09:54:21 +01:00
parent 1e67a99866
commit 31d1ecb8bd
57 changed files with 853 additions and 954 deletions

View File

@ -18,6 +18,10 @@ extension Content {
!posts.contains { $0.id == id }
}
func isNewIdForFile(_ id: String) -> Bool {
!files.contains { $0.id == id }
}
func isValidIdForTagOrPageOrPost(_ id: String) -> Bool {
id.rangeOfCharacter(from: Content.disallowedCharactersInIds) == nil
}
@ -26,6 +30,13 @@ extension Content {
id.rangeOfCharacter(from: Content.disallowedCharactersInFileIds) == nil
}
func containsPage(withUrlComponent urlComponent: String) -> Bool {
pages.contains {
$0.german.urlString == urlComponent ||
$0.english.urlString == urlComponent
}
}
func containsTag(withUrlComponent urlComponent: String) -> Bool {
(tagOverview?.contains(urlComponent: urlComponent) ?? false) ||
tags.contains { $0.contains(urlComponent: urlComponent) }