Improve page indicators, adding items

This commit is contained in:
Christoph Hagen
2025-01-09 13:27:38 +01:00
parent 0590224f02
commit 0db6e411c3
23 changed files with 238 additions and 206 deletions

View File

@ -153,8 +153,26 @@ final class Page: Item, DateItem, LocalizedItem {
content.storage.pageContent(for: id, language: language)
}
func hasContent(in language: ContentLanguage) -> Bool {
content.storage.hasPageContent(for: id, language: language)
func save(pageContent: String, in language: ContentLanguage) -> Bool {
guard content.storage.save(pageContent: pageContent, for: id, in: language) else {
return false
}
localized(in: language).hasContent = true
return true
}
/**
Update the `hasContent` property of all localized pages.
*/
func updateContentExistence() {
for language in ContentLanguage.allCases {
localized(in: language).hasContent = content.storage.hasPageContent(for: id, language: language)
}
}
/// All languages for which the page has no content
var missingContentLanguages: [ContentLanguage] {
ContentLanguage.allCases.filter { !localized(in: $0).hasContent }
}
func remove(_ file: FileResource) {