package be.simplenotes.app.views import be.simplenotes.app.utils.StaticFileResolver import be.simplenotes.app.views.components.navbar import be.simplenotes.domain.security.JwtPayload import kotlinx.html.* import kotlinx.html.stream.appendHTML abstract class View(private val staticFileResolver: StaticFileResolver) { private val styles = staticFileResolver.resolve("styles.css")!! fun renderPage( title: String, description: String? = null, jwtPayload: JwtPayload?, body: BODY.() -> Unit = {}, ) = buildString { appendLine("") appendHTML().html { attributes["lang"] = "en" head { meta(charset = "UTF-8") meta(name = "viewport", content = "width=device-width, initial-scale=1") title("$title - SimpleNotes") description?.let { meta(name = "description", content = it) } link(rel = "stylesheet", href = styles) link(rel = "shortcut icon", href = "/favicon.ico", type = "image/x-icon") } body("bg-gray-900 text-white") { navbar(jwtPayload) main { this@body.body() } } } } }