hello guys, is there any Static Content Generator ...
# javascript
m
hello guys, is there any Static Content Generator built in kotlin-js ?
👀 1
n
Nothing from what I can find. The nearest thing is Orchid ( https://github.com/orchidhq/Orchid ) , which covers certain projects including Kotlin ones ( https://orchid.run/wiki/learn/tutorials/how-to-document-kotlin ). However half of the Orchid code base uses Kotlin via Kotlin JVM, not Kotlin JS.
You could pitch a business/technical case for Kotlin JS to be used in Orchid, provided you can come up with some very good points that are very convincing.
m
thanks for the info @napperley, but I'm looking for a static only tool (html +css+javascript), maybe we can create it as project for the community.
n
i assume with static only you mean to not generate html, css or js at runtime when the user is viewing the website? that means you have to generate it at buildtime, so possibly a gradle plugin might be created eventually to automate this process if it turns out to be working well kotlinx.html does html, there is https://github.com/JetBrains/kotlin-wrappers/tree/master/kotlin-css for generating css and js can be compiled from kotlin i would create a sepeare subproject (jvm based so it can be invoked from gradle tasks easier ?) that can generate html and css files and a subproject for the js, iirc there was a plugin that changed kotlin-js (or multiplatform) to create one .js file for each kt file instead of requiring a subproject for each the rest is then just moving the files around and bundle them in a way that your app can load them at runtime or maybe i completely misinterpreted
static only content generator
one idea i had for a while is maybe use kotlin scripting that contain kotlinx.html or kotlin-css code and process a folder with those inside to produce static content (or any files really) but never had a "real" need for it so its still just a idea if thats something people are interested in i might try it out and actually make a PoC repo
m
Static Content Generator like Jekyll (https://jekyllrb.com/) for Ruby language, Pelycan (https://blog.getpelican.com/) for Python or Hugo (https://gohugo.io/) for javascript
the goal is to generate static content (html + javascript + css) with a Kotlin base, just like the tools above do
n
Is the static generation of resources only from plain text files, or does that also cover Markdown files?
n
this could very well be achieved using kotlin scripting to evaluate single .kts files for html and css difficulty is to make it actually "special" or useful over just using another tool it will also not be as fast as hugo probably, but at the very least you can write stuff in kotlin
@magnumrocha what kind of api do you imagine? cuy curremt proptotype processes this kind:
contentRoot/index.html.file.kts
Copy code
generate {
    createHTML(prettyPrint = true).html { 
        head {}
        body {
            h1{
                +"Hello"
            }
            div{
                +"World"
            }
        }
    }
}
i am considering to just use the implicit return value of the file or provide a different api to assign the string content on top of that either on library or userlevel there can be added: css, html cross file interactions might also be useful, so i am lookign into eg. a css extension pn any tag that will add its css to a global stylesheet and then add the class to the html but this is all just one late evening of trying around, most time stpent on making it work in idea and gradle properly
m
@Nikky after thinking on it, I guess the best solution should be a Gradle Plugin (in K ) to make the content generation based on its configs
this way we can take the advantage of all gradle engine (dependencies and tasks) to make the generation of the static files
in the end, this tool will be more like a "Java Static Content Generator", but backed by Gradle and Kotlin
what do you think about?
n
this is hooked into gradle, it uses the kotlin scripting, you have full access to the classpath and code in
src/main/kotlin
and at runtime it invokes the "processor" with all libraries added to the classpath
yep, thats how it makes most sense
for now i will probably make this my weekend project with a friend over, mini hackathon style and after that i will put it on github
m
nice, this weekend I will be busy, but when you share on github, share here, please... I would like to contribute 😉
n
i can add you to the github contributors already i guess
👏 1
m
please...
I loved the name 👏
n
#kontent
😆 1