Use slugger 0.1.0.1 for post titles
This commit is contained in:
parent
b96baa843e
commit
a816227da7
12
flake.lock
12
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": {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue