2022-08-29 18:57:58 +02:00
|
|
|
import Foundation
|
|
|
|
|
2022-09-09 10:59:26 +02:00
|
|
|
/**
|
|
|
|
The global configuration of the website.
|
|
|
|
*/
|
2022-09-08 09:33:27 +02:00
|
|
|
struct Configuration: Codable {
|
2022-08-29 18:57:58 +02:00
|
|
|
|
2022-09-09 10:59:26 +02:00
|
|
|
/**
|
|
|
|
The width of page content in pixels.
|
|
|
|
|
|
|
|
The width specification is used to scale images to the correct width,
|
|
|
|
when images are included in markdown content using the syntax
|
|
|
|
`![](image.jpg)`.
|
|
|
|
- Note: A high-resolution `@2x` version will be generated as well.
|
|
|
|
*/
|
2022-08-29 18:57:58 +02:00
|
|
|
let pageImageWidth: Int
|
2022-09-05 15:56:05 +02:00
|
|
|
|
2022-12-08 17:16:54 +01:00
|
|
|
/**
|
|
|
|
The maximum width (in pixels) for images shown full screen.
|
|
|
|
*/
|
|
|
|
let fullScreenImageWidth: Int
|
|
|
|
|
2022-09-09 10:59:26 +02:00
|
|
|
/**
|
|
|
|
Automatically minify all `.css` and `.js` resources which are copied
|
|
|
|
to the output folder.
|
|
|
|
- Note: This option requires the `uglifyjs` and `clean-css` tools,
|
|
|
|
which can be installed using the `install.sh` script in the root folder of the generator.
|
|
|
|
*/
|
2022-09-05 15:56:05 +02:00
|
|
|
let minifyCSSandJS: Bool
|
2022-09-05 16:08:06 +02:00
|
|
|
|
2022-09-09 10:59:26 +02:00
|
|
|
/**
|
|
|
|
The path to the directory where the root element metadata is located.
|
|
|
|
*/
|
2022-12-09 12:09:57 +01:00
|
|
|
var contentPath: String
|
2022-09-05 16:08:06 +02:00
|
|
|
|
2022-09-09 10:59:26 +02:00
|
|
|
/**
|
|
|
|
The path where the generated website should be written.
|
|
|
|
*/
|
2022-12-09 12:09:57 +01:00
|
|
|
var outputPath: String
|
2022-09-05 16:08:06 +02:00
|
|
|
|
2022-09-09 10:59:26 +02:00
|
|
|
/**
|
|
|
|
Create .md files for content pages, if they don't exist.
|
|
|
|
|
|
|
|
After the languages of the root element are read, the generator looks
|
|
|
|
for localized `.md` files for each page element which has metadata.
|
|
|
|
If it can't find a content file, it generates a placeholder.
|
|
|
|
|
|
|
|
Setting this option to `true` will cause the generator to create empty `.md`
|
|
|
|
files for each root level language. This can be helpful to see which content still needs
|
|
|
|
to be written. There is then also no need to manually create these files.
|
|
|
|
|
|
|
|
- Note: Empty content files will continue to be ignored by the generator,
|
|
|
|
and treated as if they are not present.
|
|
|
|
*/
|
|
|
|
let createMdFilesIfMissing: Bool
|
|
|
|
|
2022-09-05 16:08:06 +02:00
|
|
|
var contentDirectory: URL {
|
|
|
|
.init(fileURLWithPath: contentPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
var outputDirectory: URL {
|
|
|
|
.init(fileURLWithPath: outputPath)
|
|
|
|
}
|
2022-12-01 15:19:17 +01:00
|
|
|
|
2022-12-09 12:09:57 +01:00
|
|
|
mutating func adjustPathsRelative(to folder: URL) {
|
|
|
|
if !contentPath.hasPrefix("/") {
|
|
|
|
contentPath = folder.appendingPathComponent(contentPath).resolvingFolderTraversal()!.path
|
|
|
|
}
|
|
|
|
if !outputPath.hasPrefix("/") {
|
|
|
|
outputPath = folder.appendingPathComponent(outputPath).resolvingFolderTraversal()!.path
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-01 15:19:17 +01:00
|
|
|
func printOverview() {
|
|
|
|
print(" Source folder: \(contentDirectory.path)")
|
|
|
|
print(" Output folder: \(outputDirectory.path)")
|
|
|
|
print(" Page width: \(pageImageWidth)")
|
2022-12-08 18:21:09 +01:00
|
|
|
print(" Full-screen width: \(fullScreenImageWidth)")
|
2022-12-01 15:19:17 +01:00
|
|
|
print(" Minify JavaScript: \(minifyCSSandJS)")
|
|
|
|
print(" Minify CSS: \(minifyCSSandJS)")
|
|
|
|
print(" Create markdown files: \(createMdFilesIfMissing)")
|
|
|
|
}
|
2022-08-29 18:57:58 +02:00
|
|
|
}
|