Add highlight js

This commit is contained in:
2020-08-21 22:20:36 +02:00
parent c367d5b613
commit fa21c85a13
6 changed files with 105 additions and 1 deletions
+5 -1
View File
@@ -118,7 +118,11 @@ class NoteView(staticFileResolver: StaticFileResolver) : View(staticFileResolver
}
}
fun renderedNote(jwtPayload: JwtPayload, note: PersistedNote) = renderPage(note.meta.title, jwtPayload = jwtPayload) {
fun renderedNote(jwtPayload: JwtPayload, note: PersistedNote) = renderPage(
note.meta.title,
jwtPayload = jwtPayload,
scripts = listOf("/highlight.10.1.2.js","/init-highlight.0.0.1.js")
) {
div("container mx-auto p-4") {
div("flex items-center justify-between mb-4") {
h1("text-3xl fond-bold underline") { +note.meta.title }
+4
View File
@@ -14,6 +14,7 @@ abstract class View(private val staticFileResolver: StaticFileResolver) {
title: String,
description: String? = null,
jwtPayload: JwtPayload?,
scripts: List<String> = emptyList(),
body: MAIN.() -> Unit = {},
) = buildString {
appendLine("<!DOCTYPE html>")
@@ -26,6 +27,9 @@ abstract class View(private val staticFileResolver: StaticFileResolver) {
description?.let { meta(name = "description", content = it) }
link(rel = "stylesheet", href = styles)
link(rel = "shortcut icon", href = "/favicon.ico", type = "image/x-icon")
scripts.forEach { src ->
script(src = src) {}
}
}
body("bg-gray-900 text-white") {
navbar(jwtPayload)
File diff suppressed because one or more lines are too long
@@ -0,0 +1,5 @@
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('#note pre code').forEach((b) => {
hljs.highlightBlock(b);
});
});