From 24fa15aec99ec52adfd692edd584988f876a0343 Mon Sep 17 00:00:00 2001 From: Danielle Voznyy Date: Sun, 24 Nov 2024 22:25:01 -0500 Subject: [PATCH] feat: add tags to blog index feat: start working on a contributors page --- site/contributors.md | 5 +++++ site/contributors.yml | 6 +++++ src/Main.kt | 2 ++ src/components/Card.kt | 2 +- src/components/ContributorCard.kt | 37 +++++++++++++++++++++++++++++++ src/pages/BlogIndex.kt | 7 +++--- src/pages/Contributors.kt | 27 ++++++++++++++++++++++ 7 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 site/contributors.md create mode 100644 site/contributors.yml create mode 100644 src/components/ContributorCard.kt create mode 100644 src/pages/Contributors.kt diff --git a/site/contributors.md b/site/contributors.md new file mode 100644 index 0000000..996b7a1 --- /dev/null +++ b/site/contributors.md @@ -0,0 +1,5 @@ +--- +title: Contributors +desc: A list of Mine in Abyss project contributors +template: contributors +--- diff --git a/site/contributors.yml b/site/contributors.yml new file mode 100644 index 0000000..99db4be --- /dev/null +++ b/site/contributors.yml @@ -0,0 +1,6 @@ +Developers: + - name: "Offz" + gravatar: 4b5b974e1b62531d62abebe89b6279b122fc02cfcedfa6170d3ba0706e791af1 + blurb: This is some text +Builders: [] +Artists: [] diff --git a/src/Main.kt b/src/Main.kt index 45e02bf..5c24220 100644 --- a/src/Main.kt +++ b/src/Main.kt @@ -13,6 +13,7 @@ import me.dvyy.shocky.page.CommonFrontMatter import me.dvyy.shocky.page.Page import me.dvyy.shocky.shocky import pages.blogIndex +import pages.contributors import pages.gallery import pages.homePage import templates.blogPost @@ -33,6 +34,7 @@ suspend fun main(args: Array) = shocky { template("gallery", Page::gallery) template("home", Page::homePage) template("blog", Page::blogPost) + template("contributors", Page::contributors) pages(".") diff --git a/src/components/Card.kt b/src/components/Card.kt index 768b818..7191209 100644 --- a/src/components/Card.kt +++ b/src/components/Card.kt @@ -38,7 +38,7 @@ inline fun FlowContent.card( } } } - if (showContent) div(if (subtitle == null) "p-4" else "px-4 pb-4") { + if (showContent) div(if (image != null) "p-4" else "px-4 pb-4") { div("text-sm") { content() } diff --git a/src/components/ContributorCard.kt b/src/components/ContributorCard.kt new file mode 100644 index 0000000..f9db8cc --- /dev/null +++ b/src/components/ContributorCard.kt @@ -0,0 +1,37 @@ +package components + +import kotlinx.html.* +import kotlinx.serialization.Serializable +import java.security.MessageDigest +import kotlin.text.Charsets.UTF_8 + +@Serializable +data class Profile( + val name: String, + val gravatar: String, + val blurb: String, +) + +fun FlowContent.contributorCard(profile: Profile) = with(profile) { + + outlined { + div("not-prose flex flex-row items-center gap-4") { + lazyImg( + src = "https://gravatar.com/avatar/$gravatar?size=256", + alt = name, + classes = "w-24 h-24 rounded-l-md" + ) {} + div("flex flex-col") { + h2("text-xl font-bold") { +name } + p("text-sm") { +blurb } + } + } + } +} + +object HashUtil { + @OptIn(ExperimentalStdlibApi::class) + fun hash(input: String): String { + return MessageDigest.getInstance("SHA-256").digest(input.toByteArray(UTF_8)).toHexString() + } +} diff --git a/src/pages/BlogIndex.kt b/src/pages/BlogIndex.kt index 9192adf..a007033 100644 --- a/src/pages/BlogIndex.kt +++ b/src/pages/BlogIndex.kt @@ -3,7 +3,6 @@ package pages import components.card import kotlinx.html.div import kotlinx.html.h2 -import kotlinx.html.hr import kotlinx.html.p import me.dvyy.shocky.page.Page import me.dvyy.shocky.page.Pages @@ -22,10 +21,10 @@ fun Page.blogIndex() = default { div("not-prose grid grid-cols-1 gap-4") { posts.sortedByDescending { it.date }.forEach { post -> card(post.title, url = post.url) { + div("flex flex-row gap-2 mb-2") { + post.tags.forEach { p("text-xs font-bold uppercase text-stone-400") { +it } } + } p { +(post.desc ?: "") } -// div("flex") { -// post.tags.forEach { p { +it } } -// } } } } diff --git a/src/pages/Contributors.kt b/src/pages/Contributors.kt new file mode 100644 index 0000000..cf78fe8 --- /dev/null +++ b/src/pages/Contributors.kt @@ -0,0 +1,27 @@ +package pages + +import com.charleskorn.kaml.Yaml +import com.charleskorn.kaml.decodeFromStream +import components.Profile +import components.contributorCard +import kotlinx.html.div +import kotlinx.html.h2 +import me.dvyy.shocky.markdown +import me.dvyy.shocky.page.Page +import templates.default +import kotlin.io.path.Path +import kotlin.io.path.inputStream + +fun Page.contributors() = default { + markdown(""" + This is a WIP page we hope will showcase the cool people contributing to this project soon! + """.trimIndent()) + val contributors = + Yaml.default.decodeFromStream>>(Path("site/contributors.yml").inputStream()) + contributors.forEach { (team, profiles) -> + h2 { +team } + div("grid grid-cols-1 md:grid-cols-3 gap-4") { + for (profile in profiles) contributorCard(profile) + } + } +}