diff options
-rw-r--r-- | examples/feedblog/css/default.css (renamed from examples/rssblog/css/default.css) | 0 | ||||
-rw-r--r-- | examples/feedblog/hakyll.hs | 46 | ||||
-rw-r--r-- | examples/feedblog/index.html (renamed from examples/rssblog/index.html) | 0 | ||||
-rw-r--r-- | examples/feedblog/posts.html (renamed from examples/rssblog/posts.html) | 0 | ||||
-rw-r--r-- | examples/feedblog/posts/2009-11-05-a-first-post.markdown (renamed from examples/rssblog/posts/2009-11-05-a-first-post.markdown) | 0 | ||||
-rw-r--r-- | examples/feedblog/posts/2009-11-10-another-post.markdown (renamed from examples/rssblog/posts/2009-11-10-another-post.markdown) | 0 | ||||
-rw-r--r-- | examples/feedblog/posts/2009-11-28-a-third-post.markdown (renamed from examples/rssblog/posts/2009-11-28-a-third-post.markdown) | 0 | ||||
-rw-r--r-- | examples/feedblog/posts/2009-12-04-this-blog-aint-dead.markdown (renamed from examples/rssblog/posts/2009-12-04-this-blog-aint-dead.markdown) | 0 | ||||
-rw-r--r-- | examples/feedblog/posts/2009-12-23-almost-christmas.markdown (renamed from examples/rssblog/posts/2009-12-23-almost-christmas.markdown) | 0 | ||||
-rw-r--r-- | examples/feedblog/templates/default.html (renamed from examples/rssblog/templates/default.html) | 0 | ||||
-rw-r--r-- | examples/feedblog/templates/post.html (renamed from examples/rssblog/templates/post.html) | 0 | ||||
-rw-r--r-- | examples/feedblog/templates/postitem.html (renamed from examples/rssblog/templates/postitem.html) | 0 | ||||
-rw-r--r-- | examples/feedblog/templates/rss.xml (renamed from examples/rssblog/templates/rss.xml) | 0 | ||||
-rw-r--r-- | examples/feedblog/templates/rssitem.xml (renamed from examples/rssblog/templates/rssitem.xml) | 0 | ||||
-rw-r--r-- | examples/rssblog/hakyll.hs | 34 |
15 files changed, 46 insertions, 34 deletions
diff --git a/examples/rssblog/css/default.css b/examples/feedblog/css/default.css index 9ed2b01..9ed2b01 100644 --- a/examples/rssblog/css/default.css +++ b/examples/feedblog/css/default.css diff --git a/examples/feedblog/hakyll.hs b/examples/feedblog/hakyll.hs new file mode 100644 index 0000000..92fd4a8 --- /dev/null +++ b/examples/feedblog/hakyll.hs @@ -0,0 +1,46 @@ +module Main where + +import Control.Arrow ((>>>)) +import Text.Hakyll (hakyll) +import Text.Hakyll.Render +import Text.Hakyll.Context +import Text.Hakyll.File (getRecursiveContents, directory) +import Text.Hakyll.CreateContext (createPage, createCustomPage, createListing) +import Text.Hakyll.ContextManipulations (copyValue) +import Text.Hakyll.Feed (FeedConfiguration (..), renderRss) +import Data.List (sort) +import Control.Monad (mapM_, liftM) +import Control.Monad.Reader (liftIO) +import Data.Either (Either(..)) + +main = hakyll "http://example.com" $ do + -- Static directory. + directory css "css" + + -- Find all post paths. + postPaths <- liftM (reverse . sort) $ getRecursiveContents "posts" + let postPages = map createPage postPaths + + -- Render index, including recent posts. + let index = createListing "index.html" ["templates/postitem.html"] (take 3 postPages) [("title", Left "Home")] + renderChain ["index.html", "templates/default.html"] index + + -- Render all posts list. + let posts = createListing "posts.html" ["templates/postitem.html"] postPages [("title", Left "All posts")] + renderChain ["posts.html", "templates/default.html"] posts + + -- Render all posts. + liftIO $ putStrLn "Generating posts..." + mapM_ (renderChain ["templates/post.html", "templates/default.html"]) postPages + + -- Render RSS feed. + let + renderRss myFeedConfiguration $ + map (>>> copyValue "body" "description") (take 3 postPages) + +myFeedConfiguration = FeedConfiguration + { feedUrl = "rss.xml" + , feedTitle = "SimpleBlog RSS feed." + , feedDescription = "A simple demo of an RSS feed created with Hakyll." + , feedAuthorName = "Jasper Van der Jeugt" + } diff --git a/examples/rssblog/index.html b/examples/feedblog/index.html index 88cc0a2..88cc0a2 100644 --- a/examples/rssblog/index.html +++ b/examples/feedblog/index.html diff --git a/examples/rssblog/posts.html b/examples/feedblog/posts.html index 7db1a59..7db1a59 100644 --- a/examples/rssblog/posts.html +++ b/examples/feedblog/posts.html diff --git a/examples/rssblog/posts/2009-11-05-a-first-post.markdown b/examples/feedblog/posts/2009-11-05-a-first-post.markdown index 56b0405..56b0405 100644 --- a/examples/rssblog/posts/2009-11-05-a-first-post.markdown +++ b/examples/feedblog/posts/2009-11-05-a-first-post.markdown diff --git a/examples/rssblog/posts/2009-11-10-another-post.markdown b/examples/feedblog/posts/2009-11-10-another-post.markdown index 69b64c9..69b64c9 100644 --- a/examples/rssblog/posts/2009-11-10-another-post.markdown +++ b/examples/feedblog/posts/2009-11-10-another-post.markdown diff --git a/examples/rssblog/posts/2009-11-28-a-third-post.markdown b/examples/feedblog/posts/2009-11-28-a-third-post.markdown index 76b0606..76b0606 100644 --- a/examples/rssblog/posts/2009-11-28-a-third-post.markdown +++ b/examples/feedblog/posts/2009-11-28-a-third-post.markdown diff --git a/examples/rssblog/posts/2009-12-04-this-blog-aint-dead.markdown b/examples/feedblog/posts/2009-12-04-this-blog-aint-dead.markdown index 015ce8d..015ce8d 100644 --- a/examples/rssblog/posts/2009-12-04-this-blog-aint-dead.markdown +++ b/examples/feedblog/posts/2009-12-04-this-blog-aint-dead.markdown diff --git a/examples/rssblog/posts/2009-12-23-almost-christmas.markdown b/examples/feedblog/posts/2009-12-23-almost-christmas.markdown index cf24399..cf24399 100644 --- a/examples/rssblog/posts/2009-12-23-almost-christmas.markdown +++ b/examples/feedblog/posts/2009-12-23-almost-christmas.markdown diff --git a/examples/rssblog/templates/default.html b/examples/feedblog/templates/default.html index 1772458..1772458 100644 --- a/examples/rssblog/templates/default.html +++ b/examples/feedblog/templates/default.html diff --git a/examples/rssblog/templates/post.html b/examples/feedblog/templates/post.html index 46797a4..46797a4 100644 --- a/examples/rssblog/templates/post.html +++ b/examples/feedblog/templates/post.html diff --git a/examples/rssblog/templates/postitem.html b/examples/feedblog/templates/postitem.html index 0e62418..0e62418 100644 --- a/examples/rssblog/templates/postitem.html +++ b/examples/feedblog/templates/postitem.html diff --git a/examples/rssblog/templates/rss.xml b/examples/feedblog/templates/rss.xml index 1217b4e..1217b4e 100644 --- a/examples/rssblog/templates/rss.xml +++ b/examples/feedblog/templates/rss.xml diff --git a/examples/rssblog/templates/rssitem.xml b/examples/feedblog/templates/rssitem.xml index 48573d2..48573d2 100644 --- a/examples/rssblog/templates/rssitem.xml +++ b/examples/feedblog/templates/rssitem.xml diff --git a/examples/rssblog/hakyll.hs b/examples/rssblog/hakyll.hs deleted file mode 100644 index 50970f8..0000000 --- a/examples/rssblog/hakyll.hs +++ /dev/null @@ -1,34 +0,0 @@ -module Main where - -import Control.Monad.Reader (liftIO) -import Text.Hakyll (hakyll) -import Text.Hakyll.Render (renderAndConcat, renderChain, css) -import Text.Hakyll.File (getRecursiveContents, directory) -import Text.Hakyll.Renderables (createPagePath, createCustomPage, createListing) -import Data.List (sort) -import Control.Monad (mapM_, liftM) -import Data.Either (Either(..)) - -main = hakyll $ do - -- Static directory. - directory css "css" - - -- Find all post paths. - postPaths <- liftM (reverse . sort) $ getRecursiveContents "posts" - let renderablePosts = map createPagePath postPaths - - -- Render index, including recent posts. - let index = createListing "index.html" "templates/postitem.html" (take 3 renderablePosts) [("title", "Home")] - renderChain ["index.html", "templates/default.html"] index - - -- Render all posts list. - let posts = createListing "posts.html" "templates/postitem.html" renderablePosts [("title", "All posts")] - renderChain ["posts.html", "templates/default.html"] posts - - -- Render all posts. - liftIO $ putStrLn "Generating posts..." - mapM_ (renderChain ["templates/post.html", "templates/default.html"]) renderablePosts - - -- Render rss feed - let rss = createListing "rss.xml" "templates/rssitem.xml" (take 3 renderablePosts) [] - renderChain ["templates/rss.xml"] rss |