Discussion:
[hakyll] Loading bibliographies specified in page metadata
a***@gmail.com
2017-02-17 03:53:08 UTC
Permalink
Hi all,

I'm trying to use Hakyll to track research notebooks; basically, I have a
.bib file with a big dump of relevant papers, and keep org files with
references and comments on selected papers.

Previously I used a single bib file to track everything I commented on,
using

match "notebooks/*.org" $ do
route $ setExtension "html"
compile $ pandocBiblioCompiler "csl/apa-cv-inline.csl"
"bib/notebooks.bib"
= loadAndApplyTemplate "templates/notebook.html" postCtx
= loadAndApplyTemplate "templates/default.html"
(topCtx `mappend` defaultContext)
= relativizeUrls
But I'd like to be able to specify a bibliography in the org file's YAML
metadata, instead of hard-coding a single one. I've previously loaded
metadata into a context so it can be used in a template, but I don't see
how to load it to use as an argument to pandocBiblioCompiler. Is there a
direct way to do this?

Thanks.
--
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.
Jasper Van der Jeugt
2017-02-17 10:14:22 UTC
Permalink
You can use `getMetadataField` to pull something from the metadata.
E.g. in your case:

match "notebooks/*.org" $ do
route $ setExtension "html"
compile $ do
identifier <- getUnderlying
mbBibFile <- getMetadataField identifier "bibfile"
bibFile <- case mbBibFile of
Nothing -> fail "no bibfile specified" -- Or a default
Just bib -> return bib
pandocBiblioCompiler "csl/apa-cv-inline.csl" bibFile
Post by a***@gmail.com
= loadAndApplyTemplate "templates/notebook.html" postCtx
= loadAndApplyTemplate "templates/default.html"
(topCtx `mappend` defaultContext)
Post by a***@gmail.com
= relativizeUrls
And then just specify the `bibfile` in the metadata

---
bibfile: bib/notebooks.bib
---

...

Hope this helps,
Jasper
Post by a***@gmail.com
Hi all,
I'm trying to use Hakyll to track research notebooks; basically, I have a
.bib file with a big dump of relevant papers, and keep org files with
references and comments on selected papers.
Previously I used a single bib file to track everything I commented on,
using
match "notebooks/*.org" $ do
route $ setExtension "html"
compile $ pandocBiblioCompiler "csl/apa-cv-inline.csl"
"bib/notebooks.bib"
= loadAndApplyTemplate "templates/notebook.html" postCtx
= loadAndApplyTemplate "templates/default.html"
(topCtx `mappend` defaultContext)
= relativizeUrls
But I'd like to be able to specify a bibliography in the org file's YAML
metadata, instead of hard-coding a single one. I've previously loaded
metadata into a context so it can be used in a template, but I don't see
how to load it to use as an argument to pandocBiblioCompiler. Is there a
direct way to do this?
Thanks.
--
You received this message because you are subscribed to the Google Groups "hakyll" group.
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.
a***@gmail.com
2017-02-17 13:21:31 UTC
Permalink
Perfect, thanks. The identifier was what I was missing when I tried to
figure it out. Works great.
Post by Jasper Van der Jeugt
You can use `getMetadataField` to pull something from the metadata.
match "notebooks/*.org" $ do
route $ setExtension "html"
compile $ do
identifier <- getUnderlying
mbBibFile <- getMetadataField identifier "bibfile"
bibFile <- case mbBibFile of
Nothing -> fail "no bibfile specified" -- Or a default
Just bib -> return bib
pandocBiblioCompiler "csl/apa-cv-inline.csl" bibFile
Post by a***@gmail.com
= loadAndApplyTemplate "templates/notebook.html" postCtx
= loadAndApplyTemplate "templates/default.html"
(topCtx `mappend` defaultContext)
Post by a***@gmail.com
= relativizeUrls
And then just specify the `bibfile` in the metadata
---
bibfile: bib/notebooks.bib
---
...
Hope this helps,
Jasper
Post by a***@gmail.com
Hi all,
I'm trying to use Hakyll to track research notebooks; basically, I have
a
Post by a***@gmail.com
.bib file with a big dump of relevant papers, and keep org files with
references and comments on selected papers.
Previously I used a single bib file to track everything I commented on,
using
match "notebooks/*.org" $ do
route $ setExtension "html"
compile $ pandocBiblioCompiler "csl/apa-cv-inline.csl"
"bib/notebooks.bib"
= loadAndApplyTemplate "templates/notebook.html" postCtx
= loadAndApplyTemplate "templates/default.html"
(topCtx `mappend` defaultContext)
= relativizeUrls
But I'd like to be able to specify a bibliography in the org file's YAML
metadata, instead of hard-coding a single one. I've previously loaded
metadata into a context so it can be used in a template, but I don't see
how to load it to use as an argument to pandocBiblioCompiler. Is there a
direct way to do this?
Thanks.
--
You received this message because you are subscribed to the Google
Groups "hakyll" group.
Post by a***@gmail.com
To unsubscribe from this group and stop receiving emails from it, send
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.
Loading...