External files, improve page generation

This commit is contained in:
Christoph Hagen
2024-12-10 15:21:28 +01:00
parent 8183bc4903
commit efc9234917
50 changed files with 1069 additions and 424 deletions

View File

@ -2,9 +2,12 @@ import Foundation
final class FileToAdd: ObservableObject {
let id: Int
unowned let content: Content
let url: URL
// The external path to the file, or nil if the file is just a placeholder
let url: URL?
@Published
var uniqueId: String
@ -13,11 +16,19 @@ final class FileToAdd: ObservableObject {
var isSelected: Bool = true
init(content: Content, url: URL) {
self.id = .random()
self.content = content
self.url = url
self.uniqueId = url.lastPathComponent
}
init(content: Content, externalFile: String) {
self.id = .random()
self.content = content
self.url = nil
self.uniqueId = externalFile
}
var idAlreadyExists: Bool {
content.files.contains { $0.id == uniqueId }
}
@ -25,9 +36,6 @@ final class FileToAdd: ObservableObject {
extension FileToAdd: Identifiable {
var id: URL {
url
}
}
extension FileToAdd: Equatable {