Full page content, fixes, cleaner settings
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
|
||||
struct AdditionalPageHeaders {
|
||||
|
||||
let headers: RequiredHeaders
|
||||
|
||||
let assetPath: String
|
||||
|
||||
var content: String {
|
||||
headers.map { header in
|
||||
let module = header.asModule ? " type='module'" : ""
|
||||
return "<script\(module) src='\(assetPath)/\(header.rawValue)'></script>"
|
||||
}.sorted().joined()
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
|
||||
struct ContentBox: HtmlProducer {
|
||||
|
||||
let title: String
|
||||
|
||||
let text: String
|
||||
|
||||
func populate(_ result: inout String) {
|
||||
result += "<div class='box'>"
|
||||
result += "<span class='title'>\(title)</span>"
|
||||
result += "<p>\(text)</p>"
|
||||
result += "</div>"
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
|
||||
struct ModelViewer {
|
||||
|
||||
let file: String
|
||||
|
||||
let description: String
|
||||
|
||||
var content: String {
|
||||
"<model-viewer alt='\(description)' src='\(file)' ar shadow-intensity='1' camera-controls touch-action='pan-y'></model-viewer>"
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
|
||||
struct RelatedPageLink {
|
||||
|
||||
struct Image {
|
||||
|
||||
let url: String
|
||||
|
||||
let description: String
|
||||
|
||||
let size: Int
|
||||
}
|
||||
|
||||
let title: String
|
||||
|
||||
let description: String
|
||||
|
||||
let url: String
|
||||
|
||||
let image: Image?
|
||||
|
||||
var content: String {
|
||||
var result = ""
|
||||
result += "<a href='\(url)' class='related-box-wrapper'>"
|
||||
result += "<div class='related-box'>"
|
||||
if let image {
|
||||
result += WebsiteImage(
|
||||
rawImagePath: image.url,
|
||||
width: image.size,
|
||||
height: image.size,
|
||||
altText: image.description)
|
||||
.content
|
||||
}
|
||||
result += "<div class='related-content'>"
|
||||
result += "<h3>\(title)</h3>"
|
||||
result += "<p>\(description)</p>"
|
||||
result += "</div></div></a>" // Close related-box-wrapper, related-box
|
||||
return result
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
|
||||
struct PartialSvgImage: HtmlProducer {
|
||||
|
||||
let imagePath: String
|
||||
|
||||
let altText: String
|
||||
|
||||
let x: Int
|
||||
|
||||
let y: Int
|
||||
|
||||
let width: Int
|
||||
|
||||
let height: Int
|
||||
|
||||
private var aspectRatio: Double {
|
||||
guard height > 1 else {
|
||||
return 1
|
||||
}
|
||||
return Double(width) / Double(height)
|
||||
}
|
||||
|
||||
func populate(_ result: inout String) {
|
||||
result += "<span class='content-image svg-image'>"
|
||||
result += "<img src='\(imagePath)#svgView(viewBox(\(x), \(y), \(width), \(height)))' loading='lazy' style='aspect-ratio:\(aspectRatio)' alt='\(altText)'/>"
|
||||
result += "</span>"
|
||||
}
|
||||
}
|
||||
|
||||
struct SvgImage: HtmlProducer {
|
||||
|
||||
let imagePath: String
|
||||
|
||||
let altText: String
|
||||
|
||||
func populate(_ result: inout String) {
|
||||
result += "<div class='content-image svg-image'>"
|
||||
result += "<img src='\(imagePath)' loading='lazy' alt='\(altText)'/>"
|
||||
result += "</div>"
|
||||
}
|
||||
}
|
@@ -23,8 +23,9 @@ struct ImageGallery {
|
||||
result += "<div id='\(htmlSafeId)' class='swiper'><div class='swiper-wrapper'>"
|
||||
|
||||
guard images.count > 1 else {
|
||||
result += "<div class='swiper-slide'>"
|
||||
result += WebsiteImage(image: images[0]).content
|
||||
result += "</div></div>" // Close swiper, swiper-wrapper
|
||||
result += "</div></div></div>" // Close swiper-slide, swiper, swiper-wrapper
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -1,53 +1,36 @@
|
||||
import Foundation
|
||||
|
||||
struct NavigationBarLink {
|
||||
|
||||
let text: String
|
||||
struct NavigationBar: HtmlProducer {
|
||||
|
||||
let url: String
|
||||
}
|
||||
struct Link {
|
||||
|
||||
let text: String
|
||||
|
||||
struct NavigationBarData {
|
||||
|
||||
let navigationIconPath: String
|
||||
|
||||
let iconDescription: String
|
||||
|
||||
let navigationItems: [NavigationBarLink]
|
||||
}
|
||||
|
||||
|
||||
struct NavigationBar {
|
||||
|
||||
let data: NavigationBarData
|
||||
|
||||
init(data: NavigationBarData) {
|
||||
self.data = data
|
||||
let url: String
|
||||
}
|
||||
|
||||
private var items: [NavigationBarLink] {
|
||||
data.navigationItems
|
||||
private let links: [Link]
|
||||
|
||||
init(links: [Link]) {
|
||||
self.links = links
|
||||
}
|
||||
|
||||
var content: String {
|
||||
var result = "<nav class=\"navbar\"><div class=\"navbar-fade\"></div><div class=\"nav-center\">"
|
||||
let middleIndex = items.count / 2
|
||||
let leftNavigationItems = items[..<middleIndex]
|
||||
let rightNavigationItems = items[middleIndex...]
|
||||
func populate(_ result: inout String) {
|
||||
result += "<nav class='navbar'><div class='navbar-fade'></div><div class='nav-center'>"
|
||||
let middleIndex = links.count / 2
|
||||
let leftNavigationItems = links[..<middleIndex]
|
||||
let rightNavigationItems = links[middleIndex...]
|
||||
|
||||
for item in leftNavigationItems {
|
||||
result += "<a class=\"nav-animate\" href=\"\(item.url)\">\(item.text)</a>"
|
||||
result += "<a class='nav-animate' href='\(item.url)'>\(item.text)</a>"
|
||||
}
|
||||
|
||||
result += "<a id=\"nav-image\" href=\"/\">"
|
||||
result += "<img class=\"navbar-icon\" src=\"\(data.navigationIconPath)\" alt=\"\(data.iconDescription)\">"
|
||||
result += "</a>"
|
||||
result += "<a id='nav-image' href='/'><div class='icon-ch'></div></a>"
|
||||
|
||||
for item in rightNavigationItems {
|
||||
result += "<a class=\"nav-animate\" href=\"\(item.url)\">\(item.text)</a>"
|
||||
result += "<a class='nav-animate' href='\(item.url)'>\(item.text)</a>"
|
||||
}
|
||||
result += "</div></nav>" // Close nav-center, navbar
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user