I remember someone who had a `/drafts` folder in addition to a
`/posts` folder. I can't find the code, but it's pretty easy to
implement: posts in the drafts folder are unordered and have no
listing page (since they are just used for local previewing).
> * Sometimes I publish more than one post in a given day, and I still want
> them (reverse-)sorted by publication date & time.
Ok, so this is a little harder. I figure the way to go here is to use
an extended version of the naming format: e.g.,
"2011-07-09-15-my-post.md" for a post published at 3AM. This should
just work, except for (and this is where it gets a little harder) when
you want to display the post time on your site. In that case, you will
have to write your own version of `renderDateField` [1] (have a look
at the source code).
Cheers,
Jasper
That someone is probably me :-)
I was hoping to get round to posting my Hakyll code as a blog post at
some point, but until then, here's the gist of what I have. I tend to
run my hakyll site with "preview" as argument, which basically changes
my post paths:
main :: IO ()
main = liftIO getArgs >>= \args -> hakyll $ do
let postPath = case "preview" `elem` args of
True -> "posts/**.lhs"
False -> (predicate (\ident -> matches "posts/**.lhs" ident &&
not (matches ("posts/draft/**") ident)))
Later on, I publish the posts with the following code:
match "posts.html" $ route idRoute
create "posts.html" $ constA mempty
>>> arr (setField "title" "All posts")
>>> requireAllA postPath addPostList
>>> (requireA "tags" (setFieldA "taglist"
(renderTagList tagIdentifier :: Compiler (Tags String) String)))
>>> applyTemplateCompiler "templates/posts.html"
>>> decorate
match postPath $ do
route $ setExtension ".html"
compile $ pageCompilerWith myHakyllParserState myHakyllWriterOptions
>>> arr (renderDateField "date" "%e %B %Y" "Date unknown")
>>> arr (copyBodyToField "description")
>>> renderTagsField "taglist" tagIdentifier
>>> applyTemplateCompiler "templates/post.html"
>>> decorate
That might not be enough to go on. If not, let me know and I'd be happy to help.
>> * Sometimes I publish more than one post in a given day, and I still want
>> them (reverse-)sorted by publication date & time.
>
> Ok, so this is a little harder. I figure the way to go here is to use
> an extended version of the naming format: e.g.,
> "2011-07-09-15-my-post.md" for a post published at 3AM.
I think you mean 3pm? I'm wondering if the "right" thing to do is to
publish the whole time? For example 2011-07-09-232500. I'd be tempted
to put colons in that time, but that would make your files Windows
incompatible.
Here is a link to my file. I don't have time to figure out what exactly I did.
there are lots of processing I do on each post, but the main you want to consider is the `routing` and `compile` for "brain/*.md".
`cleanDate` is what removes the date prefix form my file.
and
`addPosted` is the function that i use to replace `renderDate` which is what Jasper was talking about
I use a drafts folder, and I don't normally worry about previewing it. When I work on a post if I want to preview it, i just move it to the published folder and use my local running instance to preview.