Skip to content

Commit

Permalink
feat(layout): cleaner layouts code with docs
Browse files Browse the repository at this point in the history
  • Loading branch information
goshatch committed Feb 3, 2025
1 parent fb3ad7d commit 1f76404
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions src/main/parts/views/layouts.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,34 @@
[hiccup2.core :refer [html]]
[parts.views.partials :as partials]))

(defn- base-layout
"Generic layout renderer based on options.
Options map can include:
:title - page title
:description - meta description
:styles - additional stylesheets
:scripts - additional scripts
:header - whether header should be rendered
:footer - whether footer should be rendered"
[options & content]
(let [default-options {:header true :footer true}
options (merge default-options options)]
(html
(partials/head options)
[:body
(when (:header options) (partials/header))
content
(when (:footer options) (partials/footer))
(partials/scripts options)])))

(defn main
"Fundamental application layout"
[options & content]
(html
(partials/head options)
[:body
(partials/header)
content
(partials/footer)
(partials/scripts options)]))
(base-layout options content))

(defn fullscreen
"Full-screen layout without header or footer"
[options & content]
(html
(partials/head options)
[:body
content
(partials/scripts options)]))
(base-layout
(merge options {:header false :footer false})
content))

0 comments on commit 1f76404

Please # to comment.