varabyte / kobweb

A modern framework for full stack web apps in Kotlin, built upon Compose HTML
https://kobweb.varabyte.com
Apache License 2.0
1.51k stars 66 forks source link

Allow the user to generate pages at build (or export?) time #88

Closed bitspittle closed 11 months ago

bitspittle commented 2 years ago

This will need a design pass. But basically, similar to what next.js is doing with static props - for example, maybe you can query a database and generate the top-level blog indexing site dynamically from it (e.g. maybe top five most visited articles, etc.)

bitspittle commented 2 years ago

Note that I'm doing this in my own blog site now simply by adding logic to my build.gradle file:

https://github.com/bitspittle/bitspittle.dev/blob/9da7def42a8b9a5481fe9805ac47de37e39f9576/build.gradle.kts#L142

so it's quite possible that we never need to do anything ourselves in Kobweb.

That said, I should review what I'm doing in my blog site and see if I could possibly expose some sort of API which makes doing what I'm doing easier to do.

bitspittle commented 11 months ago

So, yeah, at this point best practice is to

  1. create a Gradle task which generates code into a folder which is the task's output
  2. add that task as a source set directory, as in jsMain { kotlin.srcDir(genStuffTask) }