Files
saga-table-test/Sources/Site/templates/BaseLayout.swift
Michael Housh 0c6b84a872
All checks were successful
Create and publish a Docker image / build-and-push-image (push) Successful in 2m50s
feat: Initial commit.
2025-12-12 13:13:14 -05:00

54 lines
1.5 KiB
Swift

import Foundation
import HTML
/// The base page layout used to render the different sections of the website.
///
/// - Parameters:
/// - conocicalURL: The url for the page.
/// - section: The section of the page.
/// - title: The page title.
/// - rssLink: A prefix for generating an rss feed for the page (generally only used for articles).
/// - extraHeader: Any extra items to be placed in the `head` of the html.
func baseLayout(
canocicalURL: String,
section: Section,
title pageTitle: String,
rssLink: String = "",
extraHeader: NodeConvertible = Node.fragment([]),
@NodeBuilder children: () -> NodeConvertible
) -> Node {
return [
.documentType("html"),
html(lang: "en-US") {
generateHeader(pageTitle, extraHeader)
body(class: "bg-page text-white pb-5 font-avenir \(section.rawValue)") {
div(class: "content") {
children()
}
footer()
}
},
]
}
private func footer() -> Node {
div(class: "site-footer text-gray gray-links border-t border-light text-center pt-6 mt-8 text-sm")
{
p {
"Copyright © Michael Housh 2023-\(Date().description.prefix(4))."
}
p {
"Built in Swift using"
a(href: "https://github.com/loopwerk/Saga", rel: "nofollow", target: "_blank") { "Saga" }
}
}
}
private func generateHeader(_ pageTitle: String, _ extraHeader: NodeConvertible) -> Node {
head {
meta(charset: "utf-8")
title { SiteMetadata.name + ": \(pageTitle)" }
link(href: "/static/style.css", rel: "stylesheet")
}
}