cryogen-project / cryogen-core

Cryogen's core
Eclipse Public License 1.0
69 stars 62 forks source link

`parse-post-date` fails when posts are stored in subdirectories without `:date` key in post metadata #109

Closed lacarmen closed 4 years ago

lacarmen commented 6 years ago

To reproduce:

  1. Start with a fresh Cryogen template
  2. Move the 2014 posts into a 2014 folder and the 2016 post into a 2016 folder
  3. Try to compile
carmen@ouroboros [~/s/test] ⋊> lein ring server
loading module: Markdown parser
compiling assets...
                              java.lang.Thread.run              Thread.java:  745
java.util.concurrent.ThreadPoolExecutor$Worker.run  ThreadPoolExecutor.java:  617
 java.util.concurrent.ThreadPoolExecutor.runWorker  ThreadPoolExecutor.java: 1142
               java.util.concurrent.FutureTask.run          FutureTask.java:  266
                                               ...
               clojure.core/binding-conveyor-fn/fn                 core.clj: 1938
                           clojure.core/pmap/fn/fn                 core.clj: 6736
            cryogen-core.compiler/read-posts/fn/fn             compiler.clj:  151
                  cryogen-core.compiler/parse-post             compiler.clj:  131
             cryogen-core.compiler/parse-post-date             compiler.clj:   66
                        java.text.DateFormat.parse          DateFormat.java:  366
               java.text.ParseException: Unparseable date: "2014/2014-"
    errorOffset: 4
java.util.concurrent.ExecutionException: java.text.ParseException: Unparseable date: "2014/2014-"

This is because the file-name returned by page-content is 2014/2014-03-10-first-post.md and parse-post-date (used in parse-post) takes the first 10 characters of the file name to parse.


Current workaround: Add :date key to post metadata