c***@gmail.com
2016-12-31 19:07:04 UTC
This post seems to be close to what I'm after:
https://groups.google.com/forum/#!searchin/hakyll/post$20list%7Csort:relevance/hakyll/jkHracVKm_Y/mbjGakjZJC0J
Basically, I'd like to be able to get the metadata for pages from within my
template.
This gets me the *names* of the pages
match "v/**" $ do
route $ customRoute $ \ident -> dropExtension (toFilePath ident) </> "index.html"
compile $ do
ident <- getUnderlying
vCtx <- case splitDirectories $ toFilePath ident of
_:v:_ -> do
pages <- getMatches $ fromGlob $ versionsDir </> v </> "*"
return $
listField "pages" docCtx (return [Item p "" | p <- pages])
<> docCtx
other -> error $ "Expected at least 2 elements, got: " <> show other
pandocCompiler
value as the identifier.
$for(pages)$
<li>
<li class="toctree-l1">
<a class="" href="$url$">$title$</a>
</li>
</li>
$endfor$
I see that there's getMetadata, but it's not clear to me how to pack that
into an Item. Adding them as separate fields doesn't work since they need
to be in a list. Any ideas?
https://groups.google.com/forum/#!searchin/hakyll/post$20list%7Csort:relevance/hakyll/jkHracVKm_Y/mbjGakjZJC0J
Basically, I'd like to be able to get the metadata for pages from within my
template.
This gets me the *names* of the pages
match "v/**" $ do
route $ customRoute $ \ident -> dropExtension (toFilePath ident) </> "index.html"
compile $ do
ident <- getUnderlying
vCtx <- case splitDirectories $ toFilePath ident of
_:v:_ -> do
pages <- getMatches $ fromGlob $ versionsDir </> v </> "*"
return $
listField "pages" docCtx (return [Item p "" | p <- pages])
<> docCtx
other -> error $ "Expected at least 2 elements, got: " <> show other
pandocCompiler
= loadAndApplyTemplate "templates/doc.html" vCtx
= loadAndApplyTemplate "templates/default.html" vCtx
= processUrls
But I can't seem to access the $url$ or $title$, they all return the same= loadAndApplyTemplate "templates/default.html" vCtx
= processUrls
value as the identifier.
$for(pages)$
<li>
<li class="toctree-l1">
<a class="" href="$url$">$title$</a>
</li>
</li>
$endfor$
I see that there's getMetadata, but it's not clear to me how to pack that
into an Item. Adding them as separate fields doesn't work since they need
to be in a list. Any ideas?
--
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.