Use slugger 0.1.0.1 for post titles

This commit is contained in:
Robert W. Pearce 2021-07-31 06:58:54 -04:00
parent b96baa843e
commit a816227da7
No known key found for this signature in database
GPG key ID: 07A0E482E5616C9B
5 changed files with 21 additions and 37 deletions

View file

@ -2,9 +2,9 @@
import Control.Monad (forM_)
import Data.Maybe (fromMaybe)
import qualified Data.Text as T
import Hakyll
import Slug (toSlug)
import qualified Data.Text as T
import qualified Data.Text.Slugger as Slugger
import Text.Pandoc
( Extension (Ext_fenced_code_attributes, Ext_footnotes, Ext_gfm_auto_identifiers, Ext_implicit_header_references, Ext_smart),
Extensions,
@ -229,7 +229,7 @@ getTitleFromMeta =
fileNameFromTitle :: Metadata -> FilePath
fileNameFromTitle =
T.unpack . (`T.append` ".html") . toSlug . T.pack . getTitleFromMeta
T.unpack . (`T.append` ".html") . Slugger.toSlug . T.pack . getTitleFromMeta
titleRoute :: Metadata -> Routes
titleRoute =

View file

@ -1,22 +0,0 @@
{-# LANGUAGE OverloadedStrings #-}
module Slug
( toSlug,
)
where
import Data.Char (isAlphaNum)
import qualified Data.Text as T
keepAlphaNum :: Char -> Char
keepAlphaNum x
| isAlphaNum x = x
| otherwise = ' '
clean :: T.Text -> T.Text
clean =
T.map keepAlphaNum . T.replace "'" "" . T.replace "&" "and"
toSlug :: T.Text -> T.Text
toSlug =
T.intercalate (T.singleton '-') . T.words . T.toLower . clean

View file

@ -9,11 +9,10 @@ license-file: LICENSE
executable hakyll-site
main-is: Main.hs
hs-source-dirs: src
build-depends: base == 4.*
, hakyll ^>= 4.14
, pandoc
, text
, time
other-modules: Slug
build-depends: base >= 4.8
, hakyll >= 4.14
, pandoc == 2.11.*
, slugger >= 0.1.0.1
, text >= 1.2
ghc-options: -Wall -threaded
default-language: Haskell2010