Daniel Gnoutcheff
2017-08-02 15:53:40 UTC
I'd like to tell Hakyll to display posts in my 'drafts' folder when
running the `watch` command. However, I _don't_ want to add explicit
dates to those drafts. So I'd like to tell Hakyll that it should use
today's date if it's unable to parse a date from the file using
`dateField`.
Perhaps something like this would do:running the `watch` command. However, I _don't_ want to add explicit
dates to those drafts. So I'd like to tell Hakyll that it should use
today's date if it's unable to parse a date from the file using
`dateField`.
let ctx = dateField "date" "%F" `mappend`
modificationTimeField "date" "%F" `mappend`
defaultContext
pandocCompiler >>= loadAndApplyTemplate ctx "template/..."
When this context is asked to produce a "date" value, it will try
dateField first, and if that fails, it should fall through to
modificationTimeField, which uses the last-modified date on the
underlying file.
Alternatively, we could replace `modificationTimeField` with any other
context that includes a "date" field, such as
constField "date" "January 1st, 1970"
If we *really* wanted "today's date", we could construct a `buildDate`
field using `field`, `unsafeCompiler`, `getCurrentTime`, and `formatTime
(the latter two from `Data.Time`). But I suspect that one of
modificationTimeField or constField would be close enough. :)
HTH,
Daniel
--
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.