~yoctocell/yoctocell.xyz

eb97cea5abaeef4cb10177c229a363c409166bd5 — yoctocell 11 months ago cf8ba65
Add rss feed
2 files changed, 23 insertions(+), 20 deletions(-)

M index.org
M site.hs
M index.org => index.org +1 -1
@@ 7,7 7,7 @@ Welcome to my website
$partial("templates/post-list.html")$
#+end_export

You can find more posts in the [[./archive.html][archives]].
Subscribe using [[./rss.xml][RSS]].

** Source code & contributing
This website is generated from Org files using [[https://jaspervdj.be/hakyll][Hakyll]].

M site.hs => site.hs +22 -19
@@ 1,6 1,7 @@
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
import           Data.Char             (toLower)
import Data.Semigroup ((<>))
import           Data.List             (isPrefixOf)
import           Data.List.Split       (splitOn)
import           System.FilePath.Posix (joinPath, replaceExtension,


@@ 15,6 16,15 @@ import           Hakyll
config :: Configuration
config = defaultConfiguration { destinationDirectory = "_dist" }

feedConfiguration :: FeedConfiguration
feedConfiguration = FeedConfiguration { feedTitle = "yoctocell's blog"
                                      , feedDescription = "Blog posts by yoctocell"
                                      , feedAuthorName = "yoctocell"
                                      , feedAuthorEmail = "public@yoctocell.xyz"
                                      , feedRoot = "https://yoctocell.xyz"
                                      }
  

main :: IO ()
main = hakyllWith config $ do
    match "media/*" $ do


@@ 49,17 59,12 @@ main = hakyllWith config $ do
                >>= loadAndApplyTemplate "templates/default.html" archiveCtx
                >>= relativizeUrls


    match "index.org" $ do
      route tempRoute
      compile $ getResourceString >>= orgCompiler

    match "_temp/index.org" $ do
        route $ cleanRouteFromTemp
        -- compile $ pandocCompiler
        --     >>= loadAndApplyTemplate "templates/default.html" defaultContext
        --     >>= relativizeUrls

        compile $ do
            posts <- recentFirst =<< loadAll "_temp/posts/*"
            let indexCtx =


@@ 71,28 76,22 @@ main = hakyllWith config $ do
                >>= loadAndApplyTemplate "templates/default.html" indexCtx
                >>= relativizeUrls

  
    -- match "index.html" $ do
    --     route idRoute
    --     compile $ do
    --         posts <- recentFirst =<< loadAll "_temp/posts/*"
    --         let indexCtx =
    --                 listField "posts" postCtx (return posts) `mappend`
    --                 defaultContext

    --         getResourceBody
    --             >>= applyAsTemplate indexCtx
    --             >>= loadAndApplyTemplate "templates/default.html" indexCtx
    --             >>= relativizeUrls

    match blogPattern $ do
        route cleanRouteFromTemp
        compile $ do
            pandocCompiler
            >>= saveSnapshot "content"
            >>= loadAndApplyTemplate "templates/post.html"    postCtx
            >>= loadAndApplyTemplate "templates/default.html" postCtx
            >>= relativizeUrls

    create ["rss.xml"] $ do
      route idRoute
      compile $ do
        posts <- fmap (take 10) . recentFirst =<<
              loadAllSnapshots "_temp/posts/*.org" "content"
        renderRss feedConfiguration feedCtx posts

    match "templates/*" $ compile templateBodyCompiler




@@ 102,6 101,10 @@ postCtx =
    dateField "date" "%B %e, %Y" `mappend`
    defaultContext

feedCtx :: Context String
feedCtx = postCtx <> bodyField "description"


-- | From org get metadatas.
orgCompiler :: Item String -> Compiler (Item String)
orgCompiler = pure . fmap (\s -> (metadatasToStr . orgMetadatas) s ++ s)