From aec350eaf9092dfaa43cdd385a0250d6aaec7a12 Mon Sep 17 00:00:00 2001 From: etienne Date: Mon, 19 Jun 2023 23:47:41 +0200 Subject: [PATCH] Added Routes to Main. No PR right away, I feel this could take a bit more refining. --- app/Main.hs | 12 +++++++----- etienne-moqueur.cabal | 5 +++-- hie.yaml | 13 +++++++++++++ src/Core/Rules.hs | 7 +++++++ 4 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 hie.yaml create mode 100644 src/Core/Rules.hs diff --git a/app/Main.hs b/app/Main.hs index 68322fc..638eb8e 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -10,7 +10,9 @@ import Text.Blaze.Html import Components import Core.Compilers -import Core.Render +import Core.Render ( ) +import Core.Rules +import Routes import Utils.FileTree import Kit.Templates.Index ( indexTemplate ) @@ -39,21 +41,21 @@ main = hakyll $ do >>= compileTemplateItem >>= makeItem - match "posts/*.md" $ do + match' (Post "*.md") $ do route $ setExtension "html" compile $ pandocCompiler >>= loadAndApplyTemplate "src/Kit/Templates/Post.hs" defaultContext . fmap demoteHeaders - create ["index"] $ do - route $ constRoute "index.html" + create ["index.html"] $ do + route idRoute compile $ makeItem "" >>= loadAndApplyTemplate "src/Kit/Templates/Index.hs" defaultContext create [cssHash] $ do - route $ constRoute "css/default.css" + route $ constRoute . tail . path $ DefaultStylesheet compile css match (fromList . map fromFilePath $ assets) $ do diff --git a/etienne-moqueur.cabal b/etienne-moqueur.cabal index 9f987d8..755ae9d 100644 --- a/etienne-moqueur.cabal +++ b/etienne-moqueur.cabal @@ -5,10 +5,10 @@ cabal-version: 1.12 -- see: https://github.com/sol/hpack name: etienne-moqueur -version: 0.1.0.0 +version: 0.2.0.0 author: etienne maintainer: etienne@moqueur.chat -copyright: 2022 etienne +copyright: 2023 etienne license: BSD3 build-type: Simple extra-source-files: @@ -22,6 +22,7 @@ library Core.Compilers Core.Render Core.Routers + Core.Rules Core.Writer Css.Default Info diff --git a/hie.yaml b/hie.yaml new file mode 100644 index 0000000..f4c3c34 --- /dev/null +++ b/hie.yaml @@ -0,0 +1,13 @@ +cradle: + stack: + - path: "./src" + component: "etienne-moqueur:lib" + + - path: "./app/Main.hs" + component: "etienne-moqueur:exe:etienne-moqueur-exe" + + - path: "./app/Paths_etienne_moqueur.hs" + component: "etienne-moqueur:exe:etienne-moqueur-exe" + + - path: "./test" + component: "etienne-moqueur:test:etienne-moqueur-test" diff --git a/src/Core/Rules.hs b/src/Core/Rules.hs new file mode 100644 index 0000000..99962da --- /dev/null +++ b/src/Core/Rules.hs @@ -0,0 +1,7 @@ +module Core.Rules where + +import Hakyll +import Routes + +match' :: Route -> Rules () -> Rules () +match' r = match (fromGlob . tail . path $ r)