I'm working on a blog and I'm now wanting to share...
# kobweb
r
I'm working on a blog and I'm now wanting to share some kotlin code. Does anyone know of a good source for code styles for Kotlin and toml?
a
Checkout how I've done it with Kore's website https://kore.ayfri.com/ I'm using Prism with a custom theme
r
@David Herman actually used your site as an example for me. Nice! Where did you get these styles from?
🎉 1
d
I used highlight.js, although I have been planning to evaluate prism.js at some point, since I believe it has support for highlighting exact line numbers
r
You'll have to forgive me if I'm asking the wrong questions. I'm rather new.
a
It's from CSS, you have a documentation on each token available for each language
1
a
And I used the colors from my current IDE theme
r
Thanks!
a
From what I've seen Prism is far better than Highlight.js for Kotlin, you still don't have semantic highlighting which would be very sick, but it's more customisable
d
Note that I didn't create those styles myself. The JS library automatically does all that stuff for you (probably when I called the "highlightAll" method).
r
I think that gives me enough to push forward. I just noticed my Kotlin code snippits looking rather . . . bland.
d
The biggest trick to realize in a Kobweb site is that when you jump around between pages, the page does not completely reload, like a normal HTML page does. That's why official highlight.js examples are usually as simple as just putting a script in your html head block, but for Kobweb, we need to re-run highlight requests in a LaunchedEffect for every new page we visit.
r
I see. Okay. Thanks @David Herman and @Ayfri
👍 1
d
You're welcome. Good luck and let us know if you run into any issues!
👍 1
r
Had to take a break, but I THINK I just got prism working.
I had some issues with light/dark color modes and with manually highlighting, but I figured it out.
👍 1
Specifically, I needed to use the color mode as the LaunchedEffect key for when to highlight rather than the route.