From a816227da7524f6b59fee250d682740ae225575b Mon Sep 17 00:00:00 2001 From: "Robert W. Pearce" Date: Sat, 31 Jul 2021 06:58:54 -0400 Subject: [PATCH] Use slugger 0.1.0.1 for post titles --- flake.lock | 12 ++++++------ haskell-overlay.nix | 7 +++++++ ssg/src/Main.hs | 6 +++--- ssg/src/Slug.hs | 22 ---------------------- ssg/ssg.cabal | 11 +++++------ 5 files changed, 21 insertions(+), 37 deletions(-) delete mode 100644 ssg/src/Slug.hs diff --git a/flake.lock b/flake.lock index f1cf1fa..6df7dfd 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "flake-utils": { "locked": { - "lastModified": 1623660459, - "narHash": "sha256-OTmOsh43po7r5F9s9H6lVCBQ2b0FikWbmiwLbMAGRdw=", + "lastModified": 1623875721, + "narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=", "owner": "numtide", "repo": "flake-utils", - "rev": "98c8d36b1828009b20f12544214683c7489935a1", + "rev": "f7e004a55b120c02ecb6219596820fcd32ca8772", "type": "github" }, "original": { @@ -17,11 +17,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1623576761, - "narHash": "sha256-krXZQ0lObduC95f40K3JwIT//VIBpXBwVNclqh5njtE=", + "lastModified": 1627528535, + "narHash": "sha256-+E0LxCLav1GmbQbqwCKP39DRMn6NeEq00drC8udnYIY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1f91fd1040667e9265a760b0347f8bc416249da7", + "rev": "2262d7863a6af007274a698367484bf4903a3299", "type": "github" }, "original": { diff --git a/haskell-overlay.nix b/haskell-overlay.nix index c146220..8d1fbd7 100644 --- a/haskell-overlay.nix +++ b/haskell-overlay.nix @@ -18,6 +18,11 @@ final: prev: let hakyll-src = hpPrev.callHackage "hakyll" "4.14.0.0" {}; pandoc-src = hpPrev.callHackage "pandoc" "2.11.4" {}; # version specified by hayll 4.14.0.0 + slugger-src = hpPrev.callHackageDirect { + pkg = "slugger"; + ver = "0.1.0.1"; + sha256 = "sha256-ggeo5TcbI4UlK/CtG4878USX9Cm7Faz16phdjlDOGaI="; + } {}; # not available yet because it's so new in rec { hakyll = pipe hakyll-src [ doJailbreak @@ -31,6 +36,8 @@ final: prev: dontCheck ]; + slugger = slugger-src; + ssg = hpPrev.callCabal2nix "ssg" ./ssg {}; website = prev.stdenv.mkDerivation { diff --git a/ssg/src/Main.hs b/ssg/src/Main.hs index 0ff0a3f..927c158 100644 --- a/ssg/src/Main.hs +++ b/ssg/src/Main.hs @@ -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 = diff --git a/ssg/src/Slug.hs b/ssg/src/Slug.hs deleted file mode 100644 index 08d2d79..0000000 --- a/ssg/src/Slug.hs +++ /dev/null @@ -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 diff --git a/ssg/ssg.cabal b/ssg/ssg.cabal index cbc48d9..ed6c19c 100644 --- a/ssg/ssg.cabal +++ b/ssg/ssg.cabal @@ -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