add title replacement

master
Josha von Gizycki 6 years ago
parent bd6a63b258
commit b7f54b6941

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>Equilibrium page</title> <title>Equilibrium page &title</title>
</head> </head>
<body> <body>
<nav> <nav>

@ -1 +0,0 @@
jgizycki@Hastur.10236:1542010437

@ -95,16 +95,17 @@
(particles-in-content "asd &particle:hullu")) (particles-in-content "asd &particle:hullu"))
(defn fill-in-placeholders [context html page] (defn fill-in-placeholders [context html page]
(let [nav+content (-> html (let [simple (-> html
(string/replace #"&nav" (:navcode context)) (string/replace #"&nav" (:navcode context))
(string/replace #"&content" (:content page))) (string/replace #"&content" (:content page))
particles (particles-in-content nav+content)] (string/replace #"&title" (get-in page [:metadata :title])))
particles (particles-in-content simple)]
(reduce (fn [result particle] (reduce (fn [result particle]
(println particle) (println particle)
(string/replace result (string/replace result
(first particle) (first particle)
(particle-content (second particle)))) (particle-content (second particle))))
nav+content simple
particles))) particles)))
(comment (comment
@ -129,7 +130,7 @@
(defn render (defn render
"Renders all markdown pages under resources/user using the structure in resources/user/structure to target/page" "Renders all markdown pages under resources/user using the structure in resources/user/structure to target/page"
[project] [project]
(.mkdir (io/file "target/page")) (.mkdirs (io/file "target/page"))
(let [sites (md-files (str input-root "/sites")) (let [sites (md-files (str input-root "/sites"))
rendered-sites (map analysed-page sites) rendered-sites (map analysed-page sites)
index-page (index-page) index-page (index-page)

Loading…
Cancel
Save