Allow relative paths in configuration file
This commit is contained in:
@ -31,12 +31,12 @@ struct Configuration: Codable {
|
||||
/**
|
||||
The path to the directory where the root element metadata is located.
|
||||
*/
|
||||
let contentPath: String
|
||||
var contentPath: String
|
||||
|
||||
/**
|
||||
The path where the generated website should be written.
|
||||
*/
|
||||
let outputPath: String
|
||||
var outputPath: String
|
||||
|
||||
/**
|
||||
Create .md files for content pages, if they don't exist.
|
||||
@ -62,6 +62,15 @@ struct Configuration: Codable {
|
||||
.init(fileURLWithPath: outputPath)
|
||||
}
|
||||
|
||||
mutating func adjustPathsRelative(to folder: URL) {
|
||||
if !contentPath.hasPrefix("/") {
|
||||
contentPath = folder.appendingPathComponent(contentPath).resolvingFolderTraversal()!.path
|
||||
}
|
||||
if !outputPath.hasPrefix("/") {
|
||||
outputPath = folder.appendingPathComponent(outputPath).resolvingFolderTraversal()!.path
|
||||
}
|
||||
}
|
||||
|
||||
func printOverview() {
|
||||
print(" Source folder: \(contentDirectory.path)")
|
||||
print(" Output folder: \(outputDirectory.path)")
|
||||
|
Reference in New Issue
Block a user