crocodile-compiler
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.0 • Public • Published

    what if you could just start writing javascript in any text file?

    "crocodile" is the codename for this secret project to create a super simple and elegant static site generator.

    Mostly, I just thought it must be really powerful if one could actually write javascript inline any text file, like PHP.

    At the moment, javascript blocks are evaluated concurrently, however, we should be using a reducer to chug through these sequentially.

    Also, a basic CLI should be made.

    template.html

    <!doctype html>
    <html>
      <head>
        <title>
    
          <? context.title || "untitled page" ?>
    
        </title>
      <head>
      <body>
        <main>
    
          <? (context) => {
            return context.main || "no main content found"
              // Any javascript is valid.
              // The context object passed in can even contain functions.
          } ?>
    
        </main>
      </body>
    </html>
    

    crocodile.ts

    import { evaluate, read, readAll, writeAll } from "crocodile"
    
    (async function() {
    
      // Read the template.
      const template = await read("template.html").main
    
      // Read the markdown sources.
      const sources = await readAll("articles/**/*.md")
    
      // Render articles.
      const articles = sources.map(source => ({
    
        // Destined for the build directory.
        path: `build/${source.path}`,
    
        // Evaluation of <?js ?> javascript blocks, with `source` provided as context.
        main: evaluate(template, source)
      }))
    
      // Write the articles.
      await writeAll(articles)
    })()
    

    Keywords

    none

    Install

    npm i crocodile-compiler

    DownloadsWeekly Downloads

    0

    Version

    0.0.0

    License

    ISC

    Last publish

    Collaborators

    • chasemoskal