This commit is contained in:
@@ -43,6 +43,15 @@ extension Item where M == ArticleMetadata {
|
||||
}
|
||||
return primaryTag
|
||||
}
|
||||
|
||||
func getDate() -> Date {
|
||||
guard let date = metadata.date else { return date }
|
||||
return date
|
||||
}
|
||||
|
||||
func getUpdatedDate() -> Date? {
|
||||
return metadata.updated
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Most of these are taken from https://github.com/loopwerk/loopwerk.io
|
||||
|
||||
@@ -22,6 +22,13 @@ enum SiteMetadata {
|
||||
|
||||
/// Represents the valid file metadata for an article.
|
||||
struct ArticleMetadata: Metadata {
|
||||
|
||||
/// The creation date of the article.
|
||||
let date: Date?
|
||||
|
||||
/// The updated date of the article.
|
||||
let updated: Date?
|
||||
|
||||
/// The articles associated tags.
|
||||
let tags: [String]
|
||||
|
||||
|
||||
@@ -40,7 +40,8 @@ private func siteHeader(_ section: Section) -> Node {
|
||||
div(class: "header__logo") {
|
||||
a(href: "/") {
|
||||
div(class: "logo") {
|
||||
"docs.housh.dev"
|
||||
img(src: "/static/favicon-32x32.png")
|
||||
span(class: "pl-2") { "docs.housh.dev" }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,6 +51,9 @@ private func siteHeader(_ section: Section) -> Node {
|
||||
li {
|
||||
a(class: section == .articles ? "active" : "", href: "/articles/") { "Articles" }
|
||||
}
|
||||
li {
|
||||
a(href: "https://uptime.housh.dev/status/housh-dev", rel: "nofollow", target: "_blank") { "Server-Monitor" }
|
||||
}
|
||||
li {
|
||||
a(class: section == .about ? "active" : "", href: "/about.html") { "About" }
|
||||
}
|
||||
|
||||
@@ -16,7 +16,13 @@ func tagPrefix(index: Int, totalTags: Int) -> Node {
|
||||
func renderArticleInfo(_ article: Item<ArticleMetadata>) -> Node {
|
||||
div(class: "text-slate-400 gray-links text-sm mb-8") {
|
||||
span(class: "border-r border-gray pr-2 mr-2") {
|
||||
article.date.formatted("MMMM dd, yyyy")
|
||||
article.getDate().formatted("MMMM dd, yyyy")
|
||||
}
|
||||
|
||||
if let updated = article.getUpdatedDate() {
|
||||
span(class: "border-r border-gray pr-2 mr-2") {
|
||||
"Updated: \(updated.formatted("MMMM dd, yyyy"))"
|
||||
}
|
||||
}
|
||||
|
||||
%.text("\(article.body.withoutHtmlTags.numberOfWords) words, posted in ")
|
||||
@@ -94,7 +100,7 @@ func renderArticle(context: ItemRenderingContext<ArticleMetadata>) -> Node {
|
||||
title: context.item.title,
|
||||
extraHeader: generateHeader(.article(context.item))
|
||||
) {
|
||||
article(class: "pt-8 font-avenir text-lg") {
|
||||
article(class: "pt-8") {
|
||||
h1 { context.item.title }
|
||||
div {
|
||||
renderArticleInfo(context.item)
|
||||
@@ -104,7 +110,7 @@ func renderArticle(context: ItemRenderingContext<ArticleMetadata>) -> Node {
|
||||
|
||||
div(class: "border-t border-light pt-8 mt-16") {
|
||||
div(class: "grid lg:grid-cols-2") {
|
||||
h2(class: "text-4xl font-extrabold mb-8") { otherArticles.title }
|
||||
h4(class: "text-3xl text-amber-500 font-extrabold mb-8") { otherArticles.title }
|
||||
if let tag = otherArticles.tag {
|
||||
a(href: "/articles/tag/\(tag)") {
|
||||
div(class: " [&:hover]:border-b border-orange px-5 flex flex-row gap-5") {
|
||||
@@ -133,7 +139,7 @@ func renderArticle(context: ItemRenderingContext<ArticleMetadata>) -> Node {
|
||||
|
||||
func renderArticleForGrid(article: Item<ArticleMetadata>) -> Node {
|
||||
section {
|
||||
h2(class: "post-title text-2xl font-bold mb-2") {
|
||||
h3(class: "post-title text-2xl font-bold mb-2") {
|
||||
a(class: "[&:hover]:border-b border-orange-400", href: article.url) { article.title }
|
||||
}
|
||||
renderArticleInfo(article)
|
||||
|
||||
Reference in New Issue
Block a user