perun

Discuss perun static site generator
bhagany 2017-10-23T00:01:54.000009Z

@branch14 okay, the code I gave you the other day was a bit more simple than it should have been. I was able to make it work (as in, I actually ran the code), with this:

bhagany 2017-10-23T00:01:59.000085Z

(deftask global-assortment
  "Renders an assortment using global metadata"
  [o out-dir    OUTDIR     str   "the output directory"
   r renderer   RENDERER   sym   "page renderer (fully qualified symbol resolving to a function)"]
  (fn [next-task]
    (fn [fileset]
      (let [global-meta (io.perun.meta/get-global-meta fileset)
            task-fn (perun/assortment-task {:task-name "global-assortment"
                                            :renderer renderer
                                            :out-dir out-dir
                                            :filterer identity
                                            ;;:extensions [".html"]
                                            :sortby :date-published
                                            :comparator (fn [i1 i2] (compare i2 i1))
                                            :tracer :your.ns/global-assortment
                                            :grouper (partial my-grouper global-meta)})]
        ((task-fn next-task) fileset)))))

bhagany 2017-10-23T00:04:43.000136Z

The problem with the task I wrote earlier is that it was wrapping the task that gets returned from assortment-task, but not actually calling it. And then, it looks like you resolved the error that that caused (task must return fileset, or something like that) by returning the original fileset. That runs, but still doesn't actually execute the return value of assortment-task. To make it work, I used an explicit middleware pattern, instead of with-pre-wrap.

👍 2
branch14 2017-10-23T07:37:19.000233Z

@bhagany Perfect! Just tried it and it works beautifully. Thank you very much!

bhagany 2017-10-23T11:01:35.000149Z

Glad to help!