Detect duplicate ids

This commit is contained in:
Christoph Hagen 2023-12-16 22:10:50 +01:00
parent 294319a205
commit 54a4d6dbc3
2 changed files with 9 additions and 3 deletions

View File

@ -319,7 +319,7 @@ struct Element {
}
}
func getExternalPageMap(language: String) -> [String : String] {
func getExternalPageMap(language: String, log: MetadataInfoLogger) -> [String : String] {
var result = [String : String]()
if let ext = getExternalLink(for: language) {
result[id] = ext
@ -327,7 +327,10 @@ struct Element {
result[id] = path + Element.htmlPagePathAddition(for: language)
}
elements.forEach { element in
element.getExternalPageMap(language: language).forEach { key, value in
element.getExternalPageMap(language: language, log: log).forEach { key, value in
if result[key] != nil {
log.error("Page id '\(key)' is used twice", source: value)
}
result[key] = value
}
}

View File

@ -53,7 +53,10 @@ private func loadSiteData(in folder: URL, runFolder: URL) throws -> (root: Eleme
print(" Error: No site root loaded, aborting generation")
return nil
}
let pageMap = root.languages.map { (language: $0.language, pages: root.getExternalPageMap(language: $0.language)) }
let pageMap = root.languages.map { language in
(language: language.language,
pages: root.getExternalPageMap(language: language.language, log: log))
}
log.printMetadataScanOverview(languages: root.languages.count)
return (root, pageMap)
}