brandoncorrea / cljs-starter

ClojureScript-Only Starter Project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stac Website

A static website built with ClojureScript.

Setup

# clojure
brew install clojure

# node
brew install npm

# http-server
npm i http-server -g

# NPM Install
npm i

Commands

# Watch for css changes
clj -Mcss

# watch for both css/cljs changes and run specs
clj -Mtest:dev-

# build cljs on-change (for development)
clj -Mcljs auto production

# build cljs once (for production)
clj -Mcljs once production

Sandbox

Configuration

The sandbox pages will only appear in the development environment. To show them, update main.cljs with the "development" configuration.

For production, you will want these hidden. Update main.cljs to start up with "production".

Playing in the Sandbox

A sandbox page is just an implementation of page/render.

  1. Create a cljs file under src/cljs/stac/sandbox - call it whatever you'd like!
(ns stac.sandbox.example
  (:require [stac.page :as page]))

(defmethod page/render :sandbox/example [_]
  ; Your hiccup code here...
  )
  1. Add your new namespace to stac.sandbox.core
(ns stac.sandbox.core
  (:require ;...namespaces... 
            [stac.sandbox.example]
            ;...namespaces...
    ))
  1. Create a test for your new sandbox in stac.router-spec
(context "sandbox" 
  ; ...specs... 
  (it-routes "/sandbox/example" :sandbox/example)
  ; ...more specs...
  )
  1. Pass your test in stac.router
(defn def-sandbox []
  ; ...routes...
  (defroute "/sandbox/example" [] (page/install! :sandbox/example))
  ; ...more routes...
  )

Note: Your :sandbox/keyword will need to exactly match your route: "/sandbox/keyword".

Deployment

# Build cljs
clj -Mcljs once production

# Build css
clj -Mcss once

Local HTTP Server

bin/server

About

ClojureScript-Only Starter Project


Languages

Language:Clojure 88.6%Language:HTML 8.5%Language:Shell 3.0%