Make top bar link relative

This commit is contained in:
Christoph Hagen
2022-09-04 17:47:13 +02:00
parent 9a40da63d3
commit cec60e9ff2
5 changed files with 21 additions and 7 deletions

View File

@ -325,6 +325,17 @@ extension Element {
+ pageParts.dropFirst(index)
return allParts.joined(separator: "/")
}
/**
The relative path to the site root.
*/
var pathToRoot: String? {
guard path != "" else {
return nil
}
let downPathCount = path.components(separatedBy: "/").count
return [String](repeating: "..", count: downPathCount).joined(separator: "/")
}
/**
Create an absolute path (relative to the root directory) for a file contained in the elements folder.