Skip to content

Commit 24fa15a

Browse files
committed
feat: add tags to blog index
feat: start working on a contributors page
1 parent e035c16 commit 24fa15a

7 files changed

Lines changed: 81 additions & 5 deletions

File tree

site/contributors.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: Contributors
3+
desc: A list of Mine in Abyss project contributors
4+
template: contributors
5+
---

site/contributors.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Developers:
2+
- name: "Offz"
3+
gravatar: 4b5b974e1b62531d62abebe89b6279b122fc02cfcedfa6170d3ba0706e791af1
4+
blurb: This is some text
5+
Builders: []
6+
Artists: []

src/Main.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import me.dvyy.shocky.page.CommonFrontMatter
1313
import me.dvyy.shocky.page.Page
1414
import me.dvyy.shocky.shocky
1515
import pages.blogIndex
16+
import pages.contributors
1617
import pages.gallery
1718
import pages.homePage
1819
import templates.blogPost
@@ -33,6 +34,7 @@ suspend fun main(args: Array<String>) = shocky {
3334
template("gallery", Page::gallery)
3435
template("home", Page::homePage)
3536
template("blog", Page::blogPost)
37+
template("contributors", Page::contributors)
3638

3739
pages(".")
3840

src/components/Card.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ inline fun FlowContent.card(
3838
}
3939
}
4040
}
41-
if (showContent) div(if (subtitle == null) "p-4" else "px-4 pb-4") {
41+
if (showContent) div(if (image != null) "p-4" else "px-4 pb-4") {
4242
div("text-sm") {
4343
content()
4444
}

src/components/ContributorCard.kt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package components
2+
3+
import kotlinx.html.*
4+
import kotlinx.serialization.Serializable
5+
import java.security.MessageDigest
6+
import kotlin.text.Charsets.UTF_8
7+
8+
@Serializable
9+
data class Profile(
10+
val name: String,
11+
val gravatar: String,
12+
val blurb: String,
13+
)
14+
15+
fun FlowContent.contributorCard(profile: Profile) = with(profile) {
16+
17+
outlined {
18+
div("not-prose flex flex-row items-center gap-4") {
19+
lazyImg(
20+
src = "https://gravatar.com/avatar/$gravatar?size=256",
21+
alt = name,
22+
classes = "w-24 h-24 rounded-l-md"
23+
) {}
24+
div("flex flex-col") {
25+
h2("text-xl font-bold") { +name }
26+
p("text-sm") { +blurb }
27+
}
28+
}
29+
}
30+
}
31+
32+
object HashUtil {
33+
@OptIn(ExperimentalStdlibApi::class)
34+
fun hash(input: String): String {
35+
return MessageDigest.getInstance("SHA-256").digest(input.toByteArray(UTF_8)).toHexString()
36+
}
37+
}

src/pages/BlogIndex.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package pages
33
import components.card
44
import kotlinx.html.div
55
import kotlinx.html.h2
6-
import kotlinx.html.hr
76
import kotlinx.html.p
87
import me.dvyy.shocky.page.Page
98
import me.dvyy.shocky.page.Pages
@@ -22,10 +21,10 @@ fun Page.blogIndex() = default {
2221
div("not-prose grid grid-cols-1 gap-4") {
2322
posts.sortedByDescending { it.date }.forEach { post ->
2423
card(post.title, url = post.url) {
24+
div("flex flex-row gap-2 mb-2") {
25+
post.tags.forEach { p("text-xs font-bold uppercase text-stone-400") { +it } }
26+
}
2527
p { +(post.desc ?: "") }
26-
// div("flex") {
27-
// post.tags.forEach { p { +it } }
28-
// }
2928
}
3029
}
3130
}

src/pages/Contributors.kt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package pages
2+
3+
import com.charleskorn.kaml.Yaml
4+
import com.charleskorn.kaml.decodeFromStream
5+
import components.Profile
6+
import components.contributorCard
7+
import kotlinx.html.div
8+
import kotlinx.html.h2
9+
import me.dvyy.shocky.markdown
10+
import me.dvyy.shocky.page.Page
11+
import templates.default
12+
import kotlin.io.path.Path
13+
import kotlin.io.path.inputStream
14+
15+
fun Page.contributors() = default {
16+
markdown("""
17+
This is a WIP page we hope will showcase the cool people contributing to this project soon!
18+
""".trimIndent())
19+
val contributors =
20+
Yaml.default.decodeFromStream<Map<String, List<Profile>>>(Path("site/contributors.yml").inputStream())
21+
contributors.forEach { (team, profiles) ->
22+
h2 { +team }
23+
div("grid grid-cols-1 md:grid-cols-3 gap-4") {
24+
for (profile in profiles) contributorCard(profile)
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)