From e82648073a19f96d8344d0120a03184ae510e1f4 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Mon, 7 Apr 2025 10:47:51 -0700 Subject: Improves haskell --- .gitignore | 2 +- portfolio-hs.cabal | 19 ++++++++----------- site.hs | 49 ++++++++++++++++++++++--------------------------- stack.yaml | 1 + stack.yaml.lock | 12 ++++++++++++ 5 files changed, 44 insertions(+), 39 deletions(-) create mode 100644 stack.yaml create mode 100644 stack.yaml.lock diff --git a/.gitignore b/.gitignore index 4497c7b..5731bbf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ +.stack-work/ _cache/ _site/ -dist-newstyle/ diff --git a/portfolio-hs.cabal b/portfolio-hs.cabal index 2fa6a0b..8140229 100644 --- a/portfolio-hs.cabal +++ b/portfolio-hs.cabal @@ -1,17 +1,14 @@ cabal-version: 3.4 - -name: portfolio-hs -version: 0.1.0.0 -build-type: Simple +name: portfolio-hs +version: 0.1.0.0 +build-type: Simple executable site - main-is: site.hs build-depends: - base + , base , hakyll , pandoc - ghc-options: - -rtsopts - -threaded - -with-rtsopts=-N - default-language: Haskell2010 + + main-is: site.hs + ghc-options: -Wall -Wextra + default-language: GHC2021 diff --git a/site.hs b/site.hs index a02e75d..76e6f50 100644 --- a/site.hs +++ b/site.hs @@ -1,32 +1,27 @@ {-# LANGUAGE OverloadedStrings #-} -import Hakyll - ( Configuration(..) - , compile - , compressCssCompiler - , defaultConfiguration - , defaultContext - , hakyllWith - , idRoute - , loadAndApplyTemplate - , match - , pandocCompiler - , relativizeUrls - , route - , setExtension - , templateBodyCompiler - ) +import Hakyll qualified as H -config :: Configuration -config = defaultConfiguration {deployCommand = "rsync -rv _site/ debnode:portfolio"} +pandoc :: H.Compiler (H.Item String) +pandoc = + H.pandocCompiler + >>= H.loadAndApplyTemplate "templates/default.html" H.defaultContext + >>= H.relativizeUrls + +index :: H.Rules () +index = + H.match "index.md" $ do + H.route $ H.setExtension "html" + H.compile pandoc + +css :: H.Rules () +css = + H.match "css/*" $ do + H.route H.idRoute + H.compile H.compressCssCompiler + +template :: H.Rules () +template = H.match "templates/*" $ H.compile H.templateBodyCompiler main :: IO () -main = - hakyllWith config $ do - match "index.md" $ do - route $ setExtension "html" - compile $ pandocCompiler >>= loadAndApplyTemplate "templates/default.html" defaultContext >>= relativizeUrls - match "css/*" $ do - route idRoute - compile compressCssCompiler - match "templates/*" $ compile templateBodyCompiler +main = H.hakyllWith H.defaultConfiguration $ index >> css >> template diff --git a/stack.yaml b/stack.yaml new file mode 100644 index 0000000..722717e --- /dev/null +++ b/stack.yaml @@ -0,0 +1 @@ +snapshot: lts-23.18 diff --git a/stack.yaml.lock b/stack.yaml.lock new file mode 100644 index 0000000..893c60a --- /dev/null +++ b/stack.yaml.lock @@ -0,0 +1,12 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/topics/lock_files + +packages: [] +snapshots: +- completed: + sha256: d133abe75e408a407cce3f032c96ac1bbadf474a93b5156ebf4135b53382d56b + size: 683827 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/23/18.yaml + original: lts-23.18 -- cgit v1.2.1