Pavel Kretov
2014-10-19 05:09:40 UTC
Hello everybody.
I need a help with a silly question (I'm quite new to Haskell). I'd like to
add to generated pages a block of links to various social networks. I tried
to add another listField to my context, but I couldn't guess how. Please,
tell me how to fix marked line in the snippet below:
myLinks = [
("Github", "https://github.com/..."),
("Bitbucket", "https://bitbucket.org/..."),
("Stackoverflow", "http://stackoverflow.com/user/..."),
("MyAnimeList", "http://myanimelist.net/...")]
let myLinkCtx =
constField "url" `mappend`
constField "text"
let globalContext pages posts =
listField "posts" postCtx (posts) `mappend`
listField "pages" postCtx (pages) `mappend`
* -- listField "myLinks" myLinkCtx myLinks `mappend` -- DOESN'T
WORK --*
...
create ["index.html"] $ do
route idRoute
compile $ do
let context = globalContext
(recentFirst =<< loadAll ("pages/*" .&&. hasVersion
":source"))
(recentFirst =<< loadAll ("posts/*" .&&. hasVersion
":source"))
`mappend`
constField "isIndexPage" "True"
makeItem ""
Also, could you explain why I have to indent items in contexts twice?
I need a help with a silly question (I'm quite new to Haskell). I'd like to
add to generated pages a block of links to various social networks. I tried
to add another listField to my context, but I couldn't guess how. Please,
tell me how to fix marked line in the snippet below:
myLinks = [
("Github", "https://github.com/..."),
("Bitbucket", "https://bitbucket.org/..."),
("Stackoverflow", "http://stackoverflow.com/user/..."),
("MyAnimeList", "http://myanimelist.net/...")]
let myLinkCtx =
constField "url" `mappend`
constField "text"
let globalContext pages posts =
listField "posts" postCtx (posts) `mappend`
listField "pages" postCtx (pages) `mappend`
* -- listField "myLinks" myLinkCtx myLinks `mappend` -- DOESN'T
WORK --*
...
create ["index.html"] $ do
route idRoute
compile $ do
let context = globalContext
(recentFirst =<< loadAll ("pages/*" .&&. hasVersion
":source"))
(recentFirst =<< loadAll ("posts/*" .&&. hasVersion
":source"))
`mappend`
constField "isIndexPage" "True"
makeItem ""
= loadAndApplyTemplate "templates/index.html" context
= loadAndApplyTemplate "templates/default.html" context
= relativizeUrls
P. S.= loadAndApplyTemplate "templates/default.html" context
= relativizeUrls
Also, could you explain why I have to indent items in contexts twice?
--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.