no idea how metadata will work

This commit is contained in:
Pagwin 2024-07-18 17:18:01 -04:00
parent 6369d23683
commit 62c5a5abb8
No known key found for this signature in database
GPG key ID: 81137023740CA260

18
Site.hs
View file

@ -46,8 +46,8 @@ main = Shake.shakeArgs Shake.shakeOptions $ do
outputDir :: String outputDir :: String
outputDir = "publish" outputDir = "publish"
buildTargets :: Action () buildSite :: Action ()
buildTargets = do buildSite = do
-- static files -- static files
assetPaths <- Shake.getDirectoryFiles "" assetGlobs assetPaths <- Shake.getDirectoryFiles "" assetGlobs
-- path concat each asset path so it's output into the outputDir -- path concat each asset path so it's output into the outputDir
@ -60,6 +60,16 @@ buildTargets = do
postPaths <- Shake.getDirectoryFiles "" postGlobs postPaths <- Shake.getDirectoryFiles "" postGlobs
Shake.need $ map indexHtmlOutputPath postPaths Shake.need $ map indexHtmlOutputPath postPaths
-- remaining pages, index.xml = rss feed
Shake.need $ map (outputDir </>) ["index.html", "index.xml"]
-- make a rule of the pattern outputDir/asset_name which copes from outputDir/../pages
assets :: Rules ()
assets = map (outputDir </>) assetGlobs |%> \target -> do
let src = Shake.dropDirectory1 target </> "pages"
Shake.copyFileChanged src target
Shake.putInfo $ "Copied " <> target <> " from " <> src
typstToHtml :: FilePath -> Action Text typstToHtml :: FilePath -> Action Text
typstToHtml filePath = do typstToHtml filePath = do
content <- Shake.readFile' filePath content <- Shake.readFile' filePath
@ -73,6 +83,10 @@ typstToHtml filePath = do
writerOptions = writerOptions =
Pandoc.def {Pandoc.writerExtensions = Pandoc.pandocExtensions} Pandoc.def {Pandoc.writerExtensions = Pandoc.pandocExtensions}
data Page = Page {pageTitle :: Text, pageContent :: Text}
deriving (Show, Generic)
deriving (ToJSON) via PrefixedSnake "page" Page
assetGlobs :: [String] assetGlobs :: [String]
assetGlobs = ["static/*"] assetGlobs = ["static/*"]