p***@gmail.com
2018-03-04 13:48:05 UTC
Hi!
First of all, as many, I'm neither a Haskell guru nor a Hakyll one so the
question might sound silly.
I'd like to generate multiple versions of the same file (say, markdown
file) depending on a metadata.
The goal here is to be able to write some articles (but no all) in multiple
languages (French and English).
Given it's input file:
---
title: example article
language: Fr, En
---
Fr: Je suis une ligne en français.
En: Im written in English.
Je suis toujours là .
I'm always here.
I'd like look at the language metadata and output:
---
title: example article
language: Fr, En
---
Fr: Je suis une ligne en français.
Je suis toujours là .
I'm always here.
And :
---
title: example article
language: Fr, En
---
Fr: Je suis une ligne en français.
Je suis toujours là .
I'm always here.
---
My quick-fix is as follow:
type Language = String
filterLanguage :: Language -> String -> Compiler String
filterLanguage language =
unixFilter "sed"
[ "-e", "s/^" ++ language ++ ": //"
, "-e", "/^..: /d"
]
languageRoute :: Language -> Routes
languageRoute language =
customRoute createLanguageRoute `composeRoutes` setExtension "html"
where createLanguageRoute identifier =
map toLower language </> toFilePath identifier
articles :: Rules ()
articles =
forM_ ["Fr", "En"] $ \language -> do
match "articles/*" $ version language $ do
route $ languageRoute language
compile $ getResourceBody
I saw multiple pages related to my issue but none of them led me to a solution:
- https://jaspervdj.be/hakyll/tutorials/06-versions.html
- https://github.com/jaspervdj/hakyll/issues/263
- https://groups.google.com/forum/#!topic/hakyll/fpmTT8ub-nA
- https://github.com/jaspervdj/hakyll/pull/300
Many thanks in advance!
Paco V.
First of all, as many, I'm neither a Haskell guru nor a Hakyll one so the
question might sound silly.
I'd like to generate multiple versions of the same file (say, markdown
file) depending on a metadata.
The goal here is to be able to write some articles (but no all) in multiple
languages (French and English).
Given it's input file:
---
title: example article
language: Fr, En
---
Fr: Je suis une ligne en français.
En: Im written in English.
Je suis toujours là .
I'm always here.
I'd like look at the language metadata and output:
---
title: example article
language: Fr, En
---
Fr: Je suis une ligne en français.
Je suis toujours là .
I'm always here.
And :
---
title: example article
language: Fr, En
---
Fr: Je suis une ligne en français.
Je suis toujours là .
I'm always here.
---
My quick-fix is as follow:
type Language = String
filterLanguage :: Language -> String -> Compiler String
filterLanguage language =
unixFilter "sed"
[ "-e", "s/^" ++ language ++ ": //"
, "-e", "/^..: /d"
]
languageRoute :: Language -> Routes
languageRoute language =
customRoute createLanguageRoute `composeRoutes` setExtension "html"
where createLanguageRoute identifier =
map toLower language </> toFilePath identifier
articles :: Rules ()
articles =
forM_ ["Fr", "En"] $ \language -> do
match "articles/*" $ version language $ do
route $ languageRoute language
compile $ getResourceBody
= withItemBody (filterLanguage language)
= renderPandoc
= loadAndApplyTemplate "templates/article.html" articleContext
= loadAndApplyTemplate "templates/default.html" articleContext
= relativizeUrls
It allows me to have N versions of the same file but this N does not depend on the file itself.= renderPandoc
= loadAndApplyTemplate "templates/article.html" articleContext
= loadAndApplyTemplate "templates/default.html" articleContext
= relativizeUrls
I saw multiple pages related to my issue but none of them led me to a solution:
- https://jaspervdj.be/hakyll/tutorials/06-versions.html
- https://github.com/jaspervdj/hakyll/issues/263
- https://groups.google.com/forum/#!topic/hakyll/fpmTT8ub-nA
- https://github.com/jaspervdj/hakyll/pull/300
Many thanks in advance!
Paco V.
--
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.