Add route block
This commit is contained in:
@ -19,9 +19,41 @@ struct PageImage: HtmlProducer {
|
||||
/// The optional caption text below the fullscreen image
|
||||
let caption: String?
|
||||
|
||||
/// The id of the image container
|
||||
let id: String?
|
||||
|
||||
/// Additional class names for the image container
|
||||
let className: String?
|
||||
|
||||
/// Additional content for the image container
|
||||
let imageContent: String?
|
||||
|
||||
init(imageId: String, thumbnail: ImageSet, largeImage: ImageSet, caption: String?, id: String? = nil, className: String? = nil, imageContent: String? = nil) {
|
||||
self.imageId = imageId
|
||||
self.thumbnail = thumbnail
|
||||
self.largeImage = largeImage
|
||||
self.caption = caption
|
||||
self.id = id
|
||||
self.className = className
|
||||
self.imageContent = imageContent
|
||||
}
|
||||
|
||||
var idString: String {
|
||||
guard let id else { return "" }
|
||||
return " id='\(id)'"
|
||||
}
|
||||
|
||||
var classString: String {
|
||||
guard let className else { return "" }
|
||||
return " \(className)"
|
||||
}
|
||||
|
||||
func populate(_ result: inout String) {
|
||||
result += "<div class='content-image' onclick=\"document.getElementById('\(imageId)').classList.add('active')\">"
|
||||
result += "<div\(idString) class='content-image\(classString)' onclick=\"document.getElementById('\(imageId)').classList.add('active')\">"
|
||||
result += thumbnail.content
|
||||
if let imageContent {
|
||||
result += imageContent
|
||||
}
|
||||
result += "</div>"
|
||||
result += "<div id='\(imageId)' class='fullscreen-image' onclick=\"document.getElementById('\(imageId)').classList.remove('active')\">"
|
||||
result += largeImage.content
|
||||
|
Reference in New Issue
Block a user