Colors, pages, post links

This commit is contained in:
Christoph Hagen
2024-11-20 13:53:44 +01:00
parent 943d8d962b
commit 8ae2a237cc
19 changed files with 466 additions and 46 deletions

View File

@ -122,6 +122,20 @@ final class Storage {
try loadAll(in: pagesFolder)
}
func pageContent(for pageId: String, language: ContentLanguage) -> String {
let contentUrl = pageContentUrl(pageId: pageId, language: language)
guard fm.fileExists(atPath: contentUrl.path()) else {
print("No file at \(contentUrl.path())")
return "New file"
}
do {
return try String(contentsOf: contentUrl, encoding: .utf8)
} catch {
print("Failed to load page content for \(pageId) (\(language)): \(error)")
return error.localizedDescription
}
}
// MARK: Posts
/// The folder path where the markdown files of the posts are stored (by their unique id/url component)