Generate list of redirects

This commit is contained in:
Christoph Hagen
2025-01-06 10:45:48 +01:00
parent cb9af225f0
commit 48cfa204e2
3 changed files with 60 additions and 3 deletions

View File

@ -77,6 +77,8 @@ final class PageGenerationResults: ObservableObject {
private(set) var pageIsEmpty: Bool
private(set) var redirect: (originalUrl: String, newUrl: String)?
init(itemId: ItemId, delegate: GenerationResults) {
self.itemId = itemId
self.delegate = delegate
@ -100,6 +102,7 @@ final class PageGenerationResults: ObservableObject {
warnings = []
unsavedOutputFiles = [:]
pageIsEmpty = false
redirect = nil
}
func reset() {
@ -123,6 +126,7 @@ final class PageGenerationResults: ObservableObject {
warnings = []
unsavedOutputFiles = [:]
pageIsEmpty = false
redirect = nil
}
// MARK: Adding entries
@ -251,5 +255,10 @@ final class PageGenerationResults: ObservableObject {
pageIsEmpty = true
delegate.empty(.init(language: itemId.language, pageId: page.id))
}
func redirect(from originalUrl: String, to newUrl: String) {
redirect = (originalUrl, newUrl)
delegate.redirect(from: originalUrl, to: newUrl)
}
}