
/**
 An element showing a box with info about a related page.

 Contains an optional thumbnail image, a title and a description.
 */
struct RelatedPageLink: HtmlProducer {

    /// The title of the linked page
    let title: String

    /// A short description of the linked page
    let description: String

    /// The url to the linked page
    let url: String

    /// The optional thumbnail image to display
    let image: ImageSet?

    func populate(_ result: inout String) {
        result += "<a href='\(url)' class='related-box-wrapper'>"
        result += "<div class='related-box'>"
        if let image {
            result += image.content
        }
        result += "<div class='related-content'>"
        result += "<h3>\(title)</h3>"
        result += "<p>\(description)</p>"
        result += "</div></div></a>" // Close related-box-wrapper, related-box
    }
}
