Fix id of Items, saving
This commit is contained in:
@ -118,11 +118,11 @@ final class Post: Item, DateItem, LocalizedItem {
|
||||
A title for the UI, not the generation.
|
||||
*/
|
||||
override func title(in language: ContentLanguage) -> String {
|
||||
localized(in: language).title ?? id
|
||||
localized(in: language).title ?? identifier
|
||||
}
|
||||
|
||||
func contains(_ string: String) -> Bool {
|
||||
id.contains(string) ||
|
||||
identifier.contains(string) ||
|
||||
german.contains(string) ||
|
||||
english.contains(string)
|
||||
}
|
||||
@ -135,11 +135,11 @@ final class Post: Item, DateItem, LocalizedItem {
|
||||
|
||||
@discardableResult
|
||||
func update(id newId: String) -> Bool {
|
||||
guard content.storage.move(post: id, to: newId) else {
|
||||
print("Failed to move file of post \(id)")
|
||||
guard content.storage.move(post: identifier, to: newId) else {
|
||||
print("Failed to move file of post \(identifier)")
|
||||
return false
|
||||
}
|
||||
id = newId
|
||||
identifier = newId
|
||||
return true
|
||||
}
|
||||
|
||||
@ -149,10 +149,10 @@ final class Post: Item, DateItem, LocalizedItem {
|
||||
}
|
||||
|
||||
func makePage() -> Page {
|
||||
var id = self.id
|
||||
var id = self.identifier
|
||||
var number = 2
|
||||
while !content.isNewIdForPage(id) {
|
||||
id += "\(self.id)-\(number)"
|
||||
id += "\(self.identifier)-\(number)"
|
||||
number += 1
|
||||
}
|
||||
// Move tags to page
|
||||
@ -210,13 +210,13 @@ extension Post: StorageItem {
|
||||
createdDate: createdDate,
|
||||
startDate: startDate,
|
||||
endDate: endDate,
|
||||
tags: tags.map { $0.id },
|
||||
tags: tags.map { $0.identifier },
|
||||
german: german.data,
|
||||
english: english.data,
|
||||
linkedPageId: linkedPage?.id)
|
||||
linkedPageId: linkedPage?.identifier)
|
||||
}
|
||||
|
||||
func saveToDisk(_ data: Data) -> Bool {
|
||||
content.storage.save(post: data, for: id)
|
||||
content.storage.save(post: data, for: identifier)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user