-
Notifications
You must be signed in to change notification settings - Fork 410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Building post lists of multiple versions #805
Comments
Hi! A fellow user here. Do you have a minimal example of this somewhere? I don't have an answer for you offhand, but I'd like to take a look at the code and see if I can help somehow. |
Hello, thank you very much for your answer. Basically what I'm doing is that I first generate two "versions" of my markdown files: one in html and the other in pdf (this is copy pasted from https://github.com/jaspervdj/jaspervdj basically): -- posts
match "posts/*.markdown" $ do
route $ setExtension "html"
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/class.html" postCtx
>>= relativizeUrls
-- posts in PDF
match "posts/*.markdown" $ version "pdf" $ do
route $ setExtension "pdf"
compile $ do getResourceBody
>>= readPandoc
>>= writeXeTex
>>= loadAndApplyTemplate "templates/default.latex" defaultContext
>>= xelatex
where
writeXeTex :: Item Pandoc.Pandoc -> Compiler (Item String)
writeXeTex = traverse $ \pandoc ->
case Pandoc.runPure (Pandoc.writeLaTeX Pandoc.def pandoc) of
Left err -> fail $ show err
Right x -> return (T.unpack x)
xelatex :: Item String -> Compiler (Item TmpFile)
xelatex item = do
TmpFile texPath <- newTmpFile "xelatex.tex"
let tmpDir = takeDirectory texPath
pdfPath = replaceExtension texPath "pdf"
unsafeCompiler $ do
writeFile texPath $ itemBody item
_ <- Process.system $ unwords ["xelatex", "-halt-on-error",
"-output-directory", tmpDir, texPath, ">/dev/null", "2>&1"]
return ()
makeItem $ TmpFile pdfPath This generates Then I would like to do something like -- post list
create ["posts.html"] $ do
route idRoute
compile $ do
posts <- recentFirst =<< loadAll ("posts/*.markdown" .&&. hasVersion "pdf")
makeItem ""
>>= loadAndApplyTemplate "templates/archive.html" (pageCtx posts "MyPage")
>>= relativizeUrls Unfortunately it miserably fails with the error message printed above (that I reproduce below for completeness....). It works fine without the pdf part though. [ERROR] Hakyll.Core.Compiler.Require.load: test.markdown (pdf) (snapshot _final) was found in the cache, but does not have the right type: expected [Char] but got TmpFile The rest of the code is basically like in any hakyll example (copying static files, ...). |
Hmm, I don't see anything wrong with your code. I tried to reproduce the problem with my own blog by replacing Perhaps your cache is broken by some previous experiments? Try running If that doesn't help, can you please post the whole code somewhere so I can clone it and play around? Copy-pasting things from here and there is a bit slow, and I might end up with a setup that's slightly — but crucially — different from yours. |
Thanks! I'll try to put a minimal example somewhere. For the moment it's in a huge file with some useless stuff that only add noise. I'll post it during the week I guess. |
Hello,
sorry if it is a silly question. I am currently producing multiple versions of posts (html and pdf) and want to list them on a page. While have only the html version works just fine, I can't find a way to dynamically also show both versions. I usually end up with an error message like
Any idea/advice on how to have both versions in the list?
Thanks in advance for your help.
The text was updated successfully, but these errors were encountered: