|
1 | 1 | package pages |
2 | 2 |
|
3 | | -import components.card |
4 | | -import kotlinx.html.classes |
5 | | -import kotlinx.html.div |
| 3 | +import components.cardText |
| 4 | +import kotlinx.html.* |
6 | 5 | import kotlinx.serialization.Serializable |
7 | 6 | import me.dvyy.shocky.markdown |
8 | 7 | import me.dvyy.shocky.page.Page |
9 | 8 | import templates.default |
10 | | -import java.nio.file.Path |
11 | | -import kotlin.io.path.* |
12 | 9 |
|
13 | 10 | @Serializable |
14 | 11 | data class AlbumMeta( |
15 | 12 | val images: List<ImageMeta>, |
16 | 13 | ) |
17 | 14 |
|
18 | | -fun Page.album() = default { |
19 | | - classes += "max-w-screen-xl" |
| 15 | +fun Page.album() = default() { |
20 | 16 | val images = page.meta<AlbumMeta>().images |
21 | 17 | markdown(page.content) |
22 | | - div("grid grid-cols-1 space-y-4") { |
| 18 | + div("grid grid-cols-1 full-bleed") { |
| 19 | + div("md:wrapper-wide space-y-6") { |
23 | 20 | // Path("site/assets/gallery") |
24 | 21 | // .listDirectoryEntries() |
25 | 22 | // .filter { !it.nameWithoutExtension.endsWith("-min") && it.extension == "webp" } |
26 | 23 | // .map { it.relativeTo(Path("site")) to it.getImageMetaOrNull() } |
27 | | - images |
28 | | - .sortedWith(compareBy({ it.order ?: 1000.0 }/*, { it.nameWithoutExtension }*/)) |
29 | | - .forEach { meta -> |
30 | | - card( |
31 | | - meta.title, |
32 | | - subtitle = buildString { |
33 | | - if(meta.author != null) append("By ${meta.author}") |
34 | | - if (meta.desc != null) { |
35 | | - append(" — ") |
36 | | - append(meta.desc) |
37 | | - } |
38 | | - }, |
39 | | - imageClasses = "min-h-54", |
40 | | - showContent = false, |
41 | | - url = meta.url, |
42 | | - image = meta.thumbnail, |
43 | | - ) |
44 | | - } |
| 24 | + images |
| 25 | + .sortedWith(compareBy({ it.order ?: 1000.0 }/*, { it.nameWithoutExtension }*/)) |
| 26 | + .forEach { meta -> |
| 27 | + albumImage( |
| 28 | + meta.title, |
| 29 | + subtitle = buildString { |
| 30 | + if (meta.author != null) append("By ${meta.author}") |
| 31 | + if (meta.desc != null) { |
| 32 | + append(" — ") |
| 33 | + append(meta.desc) |
| 34 | + } |
| 35 | + }, |
| 36 | +// imageClasses = "min-h-54", |
| 37 | +// showContent = false, |
| 38 | +// textInsideImage = false, |
| 39 | + url = meta.url, |
| 40 | + image = meta.thumbnail, |
| 41 | + ) |
| 42 | + } |
| 43 | + } |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +inline fun FlowContent.albumImage( |
| 48 | + title: String?, |
| 49 | + subtitle: String? = null, |
| 50 | + image: String? = null, |
| 51 | + url: String? = null, |
| 52 | + crossinline icon: HTMLTag.() -> Unit = {}, |
| 53 | +) = div("not-prose") { |
| 54 | + a(href = url) { |
| 55 | + lazyImg( |
| 56 | + src = image, |
| 57 | + alt = title ?: "Untitled", |
| 58 | + classes = "drop-shadow-lg md:drop-shadow-xl w-full object-cover md:rounded-lg max-md:border-y md:border border-stone-700 min-h-54" |
| 59 | + ) { } |
| 60 | + } |
| 61 | + div("px-2 pt-2 pb-3") { |
| 62 | + cardText(icon, title, subtitle) |
45 | 63 | } |
46 | 64 | } |
0 commit comments