Add unique element id for page links

This commit is contained in:
Christoph Hagen
2022-08-30 20:09:12 +02:00
parent 7df77da67c
commit aaa9b0f4aa
3 changed files with 53 additions and 0 deletions

View File

@ -57,6 +57,13 @@ final class FileSystem {
*/
private var emptyPages: Set<String> = []
/**
All paths to page element folders, indexed by their unique id.
This relation is used to generate relative links to pages using the ``Element.id`
*/
private var pagePaths: [String: String] = [:]
/**
The image creation tasks.
@ -423,6 +430,13 @@ final class FileSystem {
}
}
func add(page: String, id: String) {
if let existing = pagePaths[id] {
log.add(error: "Conflicting id with \(existing)", source: page)
}
pagePaths[id] = page
}
// MARK: Writing files