import Foundation /** The global configuration of the website. */ struct Configuration: Codable { /** 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. */ let pageImageWidth: Int /** The maximum width (in pixels) for images shown full screen. */ let fullScreenImageWidth: Int /** Automatically minify all `.css` resources which are copied to the output folder. - Note: This option requires the `clean-css` tool, which can be installed using the `install.sh` script in the root folder of the generator. */ let minifyCSS: Bool /** Automatically minify all `.js` resources which are copied to the output folder. - Note: This option requires the `uglifyjs` tool, which can be installed using the `install.sh` script in the root folder of the generator. */ let minifyJavaScript: Bool /** The path to the directory where the root element metadata is located. */ var contentPath: String /** The path where the generated website should be written. */ var outputPath: String /** 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 var contentDirectory: URL { .init(fileURLWithPath: contentPath) } var outputDirectory: URL { .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)") print(" Page width: \(pageImageWidth)") print(" Full-screen width: \(fullScreenImageWidth)") print(" Minify JavaScript: \(minifyJavaScript)") print(" Minify CSS: \(minifyCSS)") print(" Create markdown files: \(createMdFilesIfMissing)") } }