04c652107f164d8b1841a55d039abd16b02e486d — Jack Kelly 26 days ago 0230f1d
Move slug function from Blog to Site
4 files changed, 14 insertions(+), 15 deletions(-)

M jackkelly-name.cabal
M src/Blog/Posts.hs
M src/Site.hs
R test/Blog/{PostsSpec.hs => pec.hs}
M jackkelly-name.cabal => jackkelly-name.cabal +1 -1
@@ 56,7 56,7 @@ hs-source-dirs:     test
    default-language:   Haskell2010
    ghc-options:        -Wall
-   other-modules:      Blog.PostsSpec
+   other-modules:      SiteSpec
    build-depends:      base >= 4.11.1 && < 4.13
                      , hspec >= 2.5.5 && < 2.7
                      , jackkelly-name

M src/Blog/Posts.hs => src/Blog/Posts.hs +1 -11
@@ 3,13 3,11 @@ , blogPostCompiler -- Temp for garagesale page
    , blogPostsPattern
    , blogPostContext
-   , slug
    ) where
  
  import           Blog.Util (baseBlogContext, parseBlogDate)
  import           Control.Applicative (empty)
  import           Data.Aeson (Value(..))
- import           Data.Char (toLower)
  import           Data.Default (def)
  import           Data.HashMap.Lazy ((!))
  import           Data.List (sort)


@@ 17,7 15,7 @@ import qualified Data.Text as T
  import           Data.Time (defaultTimeLocale, formatTime)
  import           Hakyll
- import           Site (sectionLabel)
+ import           Site (sectionLabel, slug)
  import           System.FilePath ((</>))
  import qualified Text.Pandoc as P
  


@@ 85,11 83,3 @@ , teaserField "teaser" "content"
      , baseBlogContext
      ]
- 
- slug :: String -> String
- slug = filter (not . (`elem` ("',!?()+:" :: String)))
-   . replace "&. " '_'
-   . map toLower
-   where
-     replace :: String -> Char -> String -> String
-     replace from to xs = [ if x `elem` from then to else x | x <- xs ]

M src/Site.hs => src/Site.hs +10 -1
@@ 1,6 1,7 @@-module Site (Url(..), baseSiteContext, sectionLabel) where
+ module Site (Url(..), baseSiteContext, sectionLabel, slug) where
  
  import Control.Lens (_1, view)
+ import Data.Char (toLower)
  import Data.List (intercalate)
  import Data.Time.Calendar (toGregorian)
  import Data.Time.Clock (getCurrentTime)


@@ 16,3 17,11 @@   sectionLabel :: [String] -> String
  sectionLabel = intercalate " | " . reverse . ("jackkelly.name":)
+ 
+ slug :: String -> String
+ slug = filter (not . (`elem` ("',!?()+:" :: String)))
+   . replace "&. " '_'
+   . map toLower
+   where
+     replace :: String -> Char -> String -> String
+     replace from to xs = [ if x `elem` from then to else x | x <- xs ]

R test/Blog/PostsSpec.hs => test/SiteSpec.hs +2 -2
@@ 1,6 1,6 @@-module Blog.PostsSpec where
+ module SiteSpec where
  
- import Blog.Posts (slug)
+ import Site (slug)
  import Data.Foldable (for_)
  import Test.Hspec