~jack/jackkelly-name

c170a7ab36f52f7d59fcdb0cfd61d362693be426 — Jack Kelly 2 years ago 192f04a
Package updates
3 files changed, 13 insertions(+), 13 deletions(-)

M jackkelly-name.cabal
M src/Blog/Archives.hs
M src/Blog/Posts.hs
M jackkelly-name.cabal => jackkelly-name.cabal +6 -6
@@ 42,19 42,19 @@ library

  ghc-options:        -Wall
  build-depends:
    , aeson                 >=1.3.1.1 && <1.6 || >=2.0 && <2.1
    , aeson                 ^>=2.0
    , base                  >=4.11.1  && <4.17
    , binary                ^>=0.8.8.0
    , bytestring            ^>=0.10
    , bytestring            >=0.10 && <0.12
    , containers            >=0.5.11  && <0.7
    , data-default          ^>=0.7.1.1
    , filepath              ^>=1.4.2
    , formatting            ^>=7.1.3
    , hakyll                ^>=4.15
    , lens                  >=4.16.1  && <4.20 || >=5.0 && <5.1
    , lens                  >=4.16.1  && <4.20 || >=5.0 && <5.2
    , monoidal-containers   >=0.4     && <0.7
    , pandoc                ^>=2.14
    , text                  ^>=1.2.3
    , pandoc                ^>=2.17
    , text                  ^>=1.2.3 || ^>= 2.0
    , time                  >=1.8.0   && <1.14
    , unordered-containers  ^>=0.2.9



@@ 67,5 67,5 @@ test-suite test
  other-modules:    SiteSpec
  build-depends:
    , base
    , hspec           >=2.7.1 && <2.9
    , hspec           >=2.7.1 && <2.10
    , jackkelly-name

M src/Blog/Archives.hs => src/Blog/Archives.hs +3 -4
@@ 1,17 1,16 @@
{-# LANGUAGE TupleSections #-}

module Blog.Archives (blogArchives) where

import           Blog.Posts (blogPostContext, blogPostsPattern)
import           Blog.Util (baseBlogContext, parseBlogDate)
import           Control.Lens (_1, _2, _3, view)
import           Data.Aeson (Value(..))
import qualified Data.Aeson.KeyMap as KM
import           Data.Foldable (for_)
import           Data.Functor ((<&>))
import           Data.HashMap.Lazy ((!))
import           Data.List (sortOn)
import           Data.Map.Monoidal (MonoidalMap)
import qualified Data.Map.Monoidal as MM
import           Data.Maybe (fromMaybe)
import qualified Data.Text as T
import           Data.Time (defaultTimeLocale, months, toGregorian)
import           Formatting ((%), (%.), formatToString, int, left)


@@ 35,7 34,7 @@ splitByDay :: [(Identifier, Metadata)] -> PostsByDay
splitByDay = foldMap postToMap . sortOn postDate
  where
    postDate (_, meta) =
      let String date = meta ! "date"
      let String date = fromMaybe (error "missing key: date") $ KM.lookup "date" meta
      in parseBlogDate $ T.unpack date

    postToMap post =

M src/Blog/Posts.hs => src/Blog/Posts.hs +4 -3
@@ 8,10 8,11 @@ module Blog.Posts
import           Blog.Util (baseBlogContext, parseBlogDate)
import           Control.Applicative (empty)
import           Data.Aeson (Value(..))
import qualified Data.Aeson.KeyMap as KM
import           Data.Default (def)
import           Data.HashMap.Lazy ((!))
import           Data.List (sort)
import qualified Data.Map as Map
import           Data.Maybe (fromMaybe)
import qualified Data.Text as T
import           Data.Time (defaultTimeLocale, formatTime)
import           Hakyll


@@ 49,10 50,10 @@ blogPostRoute = metadataRoute routeFromMeta where
      </> dateP
      </> (slug . T.unpack) title
      </> "index.html"
    String title = meta ! "title"
    String title = fromMaybe (error "missing key: title") $ KM.lookup "title" meta
    dateP = formatTime defaultTimeLocale "%Y/%m/%d" date
    date = parseBlogDate . T.unpack $ dateS
    String dateS = meta ! "date"
    String dateS = fromMaybe (error "missing key: date") $ KM.lookup "date" meta

blogPostCompiler :: Compiler (Item String)
blogPostCompiler = pandocCompilerWith readerOptions writerOptions where