Skip to content

Commit

Permalink
feat: add tags to blog index
Browse files Browse the repository at this point in the history
feat: start working on a contributors page
  • Loading branch information
0ffz committed Nov 25, 2024
1 parent e035c16 commit 24fa15a
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 5 deletions.
5 changes: 5 additions & 0 deletions site/contributors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Contributors
desc: A list of Mine in Abyss project contributors
template: contributors
---
6 changes: 6 additions & 0 deletions site/contributors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Developers:
- name: "Offz"
gravatar: 4b5b974e1b62531d62abebe89b6279b122fc02cfcedfa6170d3ba0706e791af1
blurb: This is some text
Builders: []
Artists: []
2 changes: 2 additions & 0 deletions src/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,6 +34,7 @@ suspend fun main(args: Array<String>) = shocky {
template("gallery", Page::gallery)
template("home", Page::homePage)
template("blog", Page::blogPost)
template("contributors", Page::contributors)

pages(".")

Expand Down
2 changes: 1 addition & 1 deletion src/components/Card.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
37 changes: 37 additions & 0 deletions src/components/ContributorCard.kt
Original file line number Diff line number Diff line change
@@ -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()
}
}
7 changes: 3 additions & 4 deletions src/pages/BlogIndex.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 } }
// }
}
}
}
Expand Down
27 changes: 27 additions & 0 deletions src/pages/Contributors.kt
Original file line number Diff line number Diff line change
@@ -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<Map<String, List<Profile>>>(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)
}
}
}

0 comments on commit 24fa15a

Please sign in to comment.