Allow custom thumbnail paths in metadata

This commit is contained in:
Christoph Hagen
2022-09-29 21:23:41 +02:00
parent 9d2f1e4c90
commit c82080db82
7 changed files with 97 additions and 60 deletions

View File

@ -265,7 +265,7 @@ struct PageContentGenerator {
content[.title] = linkedPage.title(for: language)
let fullThumbnailPath = linkedPage.thumbnailFilePath(for: language)
let fullThumbnailPath = linkedPage.thumbnailFilePath(for: language).destination
let relativeImageUrl = page.relativePathToOtherSiteElement(file: fullThumbnailPath)
let metadata = linkedPage.localized(for: language)

View File

@ -21,7 +21,7 @@ struct PageHeadGenerator {
// Note: Generate separate destination link for the image,
// since we don't want a single large image for thumbnails.
// Warning: Link preview source path must be relative to root
let linkPreviewImageName = image.insert("-link", beforeLast: ".")
let linkPreviewImageName = "thumbnail-link.\(image.lastComponentAfter("."))"
let sourceImagePath = page.pathRelativeToRootForContainedInputFile(image)
let destinationImagePath = page.pathRelativeToRootForContainedInputFile(linkPreviewImageName)
files.requireImage(

View File

@ -14,8 +14,8 @@ struct ThumbnailListGenerator {
}
private func itemContent(_ item: Element, parent: Element, language: String, style: ThumbnailStyle) -> String {
let fullThumbnailPath = item.thumbnailFilePath(for: language)
let relativeImageUrl = parent.relativePathToFileWithPath(fullThumbnailPath)
let (thumbnailSourcePath, thumbnailDestPath) = item.thumbnailFilePath(for: language)
let relativeImageUrl = parent.relativePathToFileWithPath(thumbnailDestPath)
let metadata = item.localized(for: language)
var content = [ThumbnailKey : String]()
@ -37,16 +37,16 @@ struct ThumbnailListGenerator {
}
files.requireImage(
source: fullThumbnailPath,
destination: fullThumbnailPath,
source: thumbnailSourcePath,
destination: thumbnailDestPath,
requiredBy: item.path,
width: style.width,
desiredHeight: style.height)
// Create image version for high-resolution screens
files.requireImage(
source: fullThumbnailPath,
destination: fullThumbnailPath.insert("@2x", beforeLast: "."),
source: thumbnailSourcePath,
destination: thumbnailDestPath.insert("@2x", beforeLast: "."),
requiredBy: item.path,
width: style.width * 2,
desiredHeight: style.height * 2)