diff --git a/Sources/Generator/Files/FileSystem.swift b/Sources/Generator/Files/FileSystem.swift index 3a2656e..d571639 100644 --- a/Sources/Generator/Files/FileSystem.swift +++ b/Sources/Generator/Files/FileSystem.swift @@ -228,7 +228,6 @@ final class FileSystem { } @discardableResult - func requireImage(source: String, destination: String, width: Int, desiredHeight: Int? = nil) -> NSSize { let height = desiredHeight.unwrapped(CGFloat.init) let sourceUrl = input.appendingPathComponent(source) let image = ImageOutput(source: source, width: width, desiredHeight: desiredHeight) @@ -266,6 +265,7 @@ final class FileSystem { imageTasks[destination] = image } return scaledSize + func requireImage(source: String, destination: String, requiredBy path: String, width: Int, desiredHeight: Int? = nil) -> NSSize { } func createImages() { diff --git a/Sources/Generator/Generators/MarkdownProcessor.swift b/Sources/Generator/Generators/MarkdownProcessor.swift index c9bf97d..58cd0b3 100644 --- a/Sources/Generator/Generators/MarkdownProcessor.swift +++ b/Sources/Generator/Generators/MarkdownProcessor.swift @@ -109,11 +109,19 @@ struct PageContentGenerator { private func handleImage(page: Element, file: String, rightTitle: String?, leftTitle: String?) -> String { let imagePath = page.pathRelativeToRootForContainedInputFile(file) - let size = files.requireImage(source: imagePath, destination: imagePath, width: configuration.pageImageWidth) + let size = files.requireImage( + source: imagePath, + destination: imagePath, + requiredBy: page.path, + width: configuration.pageImageWidth) let imagePath2x = imagePath.insert("@2x", beforeLast: ".") let file2x = file.insert("@2x", beforeLast: ".") - files.requireImage(source: imagePath, destination: imagePath2x, width: 2 * configuration.pageImageWidth) + files.requireImage( + source: imagePath, + destination: imagePath2x, + requiredBy: page.path, + width: 2 * configuration.pageImageWidth) let content: [PageImageTemplate.Key : String] = [ .image: file, diff --git a/Sources/Generator/Generators/PageHeadGenerator.swift b/Sources/Generator/Generators/PageHeadGenerator.swift index ffe41ba..7495370 100644 --- a/Sources/Generator/Generators/PageHeadGenerator.swift +++ b/Sources/Generator/Generators/PageHeadGenerator.swift @@ -27,6 +27,7 @@ struct PageHeadGenerator { files.requireImage( source: sourceImagePath, destination: destinationImagePath, + requiredBy: page.path, width: PageHeadGenerator.linkPreviewDesiredImageWidth) content[.image] = factory.html.linkPreviewImage(file: linkPreviewImageName) } diff --git a/Sources/Generator/Generators/SiteGenerator.swift b/Sources/Generator/Generators/SiteGenerator.swift index 1acd7ae..7caba8a 100644 --- a/Sources/Generator/Generators/SiteGenerator.swift +++ b/Sources/Generator/Generators/SiteGenerator.swift @@ -53,6 +53,7 @@ struct SiteGenerator { files.requireImage( source: $0.sourcePath, destination: $0.destinationPath, + requiredBy: element.path, width: $0.desiredWidth, desiredHeight: $0.desiredHeight) } diff --git a/Sources/Generator/Generators/ThumbnailListGenerator.swift b/Sources/Generator/Generators/ThumbnailListGenerator.swift index d3f473a..f45f648 100644 --- a/Sources/Generator/Generators/ThumbnailListGenerator.swift +++ b/Sources/Generator/Generators/ThumbnailListGenerator.swift @@ -39,6 +39,7 @@ struct ThumbnailListGenerator { files.requireImage( source: fullThumbnailPath, destination: fullThumbnailPath, + requiredBy: item.path, width: style.width, desiredHeight: style.height) @@ -46,6 +47,7 @@ struct ThumbnailListGenerator { files.requireImage( source: fullThumbnailPath, destination: fullThumbnailPath.insert("@2x", beforeLast: "."), + requiredBy: item.path, width: style.width * 2, desiredHeight: style.height * 2)