Fix links to external pages

This commit is contained in:
Christoph Hagen
2022-12-05 17:25:07 +01:00
parent 464ece4a03
commit deb7e6187e
4 changed files with 36 additions and 25 deletions

View File

@ -8,6 +8,8 @@ enum MinificationType {
case css
}
typealias PageMap = [(language: String, pages: [String : String])]
final class GenerationResultsHandler {
/// The content folder where the input data is stored
@ -23,7 +25,7 @@ final class GenerationResultsHandler {
This relation is used to generate relative links to pages using the ``Element.id`
*/
private let pagePaths: [String: String]
private let pageMap: PageMap
private let configuration: Configuration
@ -31,11 +33,11 @@ final class GenerationResultsHandler {
private let numberOfTotalPages: Int
init(in input: URL, to output: URL, configuration: Configuration, fileUpdates: FileUpdateChecker, pagePaths: [String: String], pageCount: Int) {
init(in input: URL, to output: URL, configuration: Configuration, fileUpdates: FileUpdateChecker, pageMap: PageMap, pageCount: Int) {
self.contentFolder = input
self.fileUpdates = fileUpdates
self.outputFolder = output
self.pagePaths = pagePaths
self.pageMap = pageMap
self.configuration = configuration
self.numberOfTotalPages = pageCount
}
@ -86,8 +88,8 @@ final class GenerationResultsHandler {
// MARK: Page data
func getPagePath(for id: String, source: String) -> String? {
guard let pagePath = pagePaths[id] else {
func getPagePath(for id: String, source: String, language: String) -> String? {
guard let pagePath = pageMap.first(where: { $0.language == language})?.pages[id] else {
missingLinkedPages[id] = source
return nil
}