Make images from md folders available, so a post or page can be one unit in a folder
This commit is contained in:
parent
6aca634f89
commit
d9fe01d8f6
2 changed files with 10 additions and 2 deletions
|
@ -1,7 +1,8 @@
|
||||||
(ns cryogen-core.compiler
|
(ns cryogen-core.compiler
|
||||||
(:require [selmer.parser :refer [cache-off! render-file]]
|
(:require [selmer.parser :refer [cache-off! render-file]]
|
||||||
[cryogen-core.io :refer
|
[cryogen-core.io :refer
|
||||||
[get-resource find-assets create-folder wipe-public-folder copy-resources]]
|
[get-resource find-assets create-folder wipe-public-folder copy-resources
|
||||||
|
copy-images-from-markdown-folders]]
|
||||||
[cryogen-core.sitemap :as sitemap]
|
[cryogen-core.sitemap :as sitemap]
|
||||||
[cryogen-core.rss :as rss]
|
[cryogen-core.rss :as rss]
|
||||||
[io.aviso.exception :refer [write-exception]]
|
[io.aviso.exception :refer [write-exception]]
|
||||||
|
@ -288,6 +289,7 @@
|
||||||
(wipe-public-folder keep-files)
|
(wipe-public-folder keep-files)
|
||||||
(println (blue "copying resources"))
|
(println (blue "copying resources"))
|
||||||
(copy-resources config)
|
(copy-resources config)
|
||||||
|
(copy-images-from-markdown-folders config)
|
||||||
(compile-pages default-params pages config)
|
(compile-pages default-params pages config)
|
||||||
(compile-posts default-params posts config)
|
(compile-posts default-params posts config)
|
||||||
(compile-tags default-params posts-by-tag config)
|
(compile-tags default-params posts-by-tag config)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
(ns cryogen-core.io
|
(ns cryogen-core.io
|
||||||
(:require [clojure.java.io :refer [file]]
|
(:require [clojure.java.io :refer [file]]
|
||||||
[me.raynes.fs :as fs]))
|
[me.raynes.fs :as fs]
|
||||||
|
[clojure.java.io :as io]))
|
||||||
|
|
||||||
(def public "resources/public")
|
(def public "resources/public")
|
||||||
|
|
||||||
|
@ -26,6 +27,11 @@
|
||||||
(doseq [path (.listFiles (file public) filenamefilter)]
|
(doseq [path (.listFiles (file public) filenamefilter)]
|
||||||
(fs/delete-dir path))))
|
(fs/delete-dir path))))
|
||||||
|
|
||||||
|
(defn copy-images-from-markdown-folders [{:keys [blog-prefix]}]
|
||||||
|
(let [blog-prefix-relative (if (= \/ (first blog-prefix)) (subs blog-prefix 1) blog-prefix)]
|
||||||
|
(doseq [asset (fs/find-files "resources/templates" #".+(jpg|jpeg|png|gif)")]
|
||||||
|
(fs/copy asset (io/file public blog-prefix-relative "img" (.getName asset))))))
|
||||||
|
|
||||||
(defn copy-resources [{:keys [blog-prefix resources]}]
|
(defn copy-resources [{:keys [blog-prefix resources]}]
|
||||||
(doseq [resource resources]
|
(doseq [resource resources]
|
||||||
(let [src (str "resources/templates/" resource)
|
(let [src (str "resources/templates/" resource)
|
||||||
|
|
Loading…
Reference in a new issue