summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pages/playlists.html (renamed from playlists.html)0
-rw-r--r--site.hs55
-rw-r--r--skiletro.cabal1
-rw-r--r--templates/default.html6
-rw-r--r--templates/post.html4
5 files changed, 54 insertions, 12 deletions
diff --git a/playlists.html b/pages/playlists.html
index b11cfad..b11cfad 100644
--- a/playlists.html
+++ b/pages/playlists.html
diff --git a/site.hs b/site.hs
index dffdd47..dfc2cc7 100644
--- a/site.hs
+++ b/site.hs
@@ -1,9 +1,12 @@
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
-import Data.Monoid (mappend)
+import Data.List (isInfixOf, sortBy)
+import Data.Monoid (mappend)
import Hakyll
-import Hakyll.Web.Sass (sassCompiler)
+import Hakyll.Web.Sass (sassCompiler)
+import System.FilePath.Posix (splitFileName, takeBaseName,
+ takeDirectory, (</>))
--------------------------------------------------------------------------------
main :: IO ()
@@ -21,24 +24,34 @@ main = hakyll $ do
let compressCssItem = fmap compressCss
compile (compressCssItem <$> sassCompiler)
- match (fromList ["playlists.html", "404.html"]) $ do
- route $ setExtension "html"
+ match "404.html" $ do
+ route idRoute
+ compile $
+ pandocCompiler
+ >>= loadAndApplyTemplate "templates/default.html" defaultContext
+ >>= relativizeUrls
+ >>= removeIndexHtml
+
+ match "pages/*.html" $ do
+ route prettyRoute
compile $
pandocCompiler
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls
+ >>= removeIndexHtml
match "posts/*" $ do
- route $ setExtension "html"
+ route prettyRoute
compile $
pandocCompiler
>>= loadAndApplyTemplate "templates/post.html" postCtx
>>= saveSnapshot "content"
>>= loadAndApplyTemplate "templates/default.html" postCtx
>>= relativizeUrls
+ >>= removeIndexHtml
create ["archive.html"] $ do
- route idRoute
+ route prettyRoute
compile $ do
posts <- recentFirst =<< loadAll "posts/*"
let archiveCtx =
@@ -50,6 +63,7 @@ main = hakyll $ do
>>= loadAndApplyTemplate "templates/archive.html" archiveCtx
>>= loadAndApplyTemplate "templates/default.html" archiveCtx
>>= relativizeUrls
+ >>= removeIndexHtml
create ["atom.xml"] $ do
route idRoute
@@ -81,6 +95,7 @@ main = hakyll $ do
>>= applyAsTemplate indexCtx
>>= loadAndApplyTemplate "templates/default.html" indexCtx
>>= relativizeUrls
+ >>= removeIndexHtml
match "templates/*" $ compile templateBodyCompiler
@@ -95,11 +110,37 @@ feedConfiguration =
feedRoot = "https://skiletro.com"
}
+--------------------------------------------------------------------------------
+
+prettyRoute :: Routes
+prettyRoute = customRoute createIndexRoute
+ where
+ createIndexRoute ident =
+ takeDirectory p </> takeBaseName p </> "index.html"
+ where
+ p = toFilePath ident
+
+removeIndexHtml :: Item String -> Compiler (Item String)
+removeIndexHtml item = return $ fmap (withUrls removeIndexStr) item
+ where
+ removeIndexStr :: String -> String
+ removeIndexStr url = case splitFileName url of
+ (dir, "index.html") | isLocal dir -> dir
+ _ -> url
+ where
+ isLocal uri = not (isInfixOf "://" uri)
+
+--------------------------------------------------------------------------------
+
postCtx :: Context String
-postCtx = hDateCtx <> cDateCtx <> defaultContext
+postCtx = hDateCtx <> cDateCtx <> modifiedCtx <> defaultContext
hDateCtx :: Context String
hDateCtx = dateField "hdate" "%B %e, %Y"
cDateCtx :: Context String
cDateCtx = dateField "cdate" "%Y-%m-%d"
+
+modifiedCtx :: Context String
+modifiedCtx = modificationTimeField "modified" "%B %e, %Y"
+--------------------------------------------------------------------------------
diff --git a/skiletro.cabal b/skiletro.cabal
index 36dda08..2eb185b 100644
--- a/skiletro.cabal
+++ b/skiletro.cabal
@@ -6,6 +6,7 @@ cabal-version: >= 1.10
executable site
main-is: site.hs
build-depends: base == 4.*
+ , filepath
, hakyll == 4.16.*
, hakyll-sass == 0.2.*
ghc-options: -threaded -rtsopts -with-rtsopts=-N
diff --git a/templates/default.html b/templates/default.html
index af8ada0..3cab4b4 100644
--- a/templates/default.html
+++ b/templates/default.html
@@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
- <title>$title$ | skiletro</title>
+ <title>$title$ | Skiletro</title>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="description" content="" />
<link rel="stylesheet" type="text/css" href="/css/default.css" />
@@ -74,8 +74,8 @@
></a>
<hr />
<a href="/">Home</a>
- <a href="/archive.html">Archive</a>
- <a href="/playlists.html">Playlists</a>
+ <a href="/archive">Archive</a>
+ <a href="/pages/playlists">Playlists</a>
<hr />
<img src="/images/nonbinary-flag.svg" width="20rem" height="20rem" />
</nav>
diff --git a/templates/post.html b/templates/post.html
index 6d94c31..cfcd59b 100644
--- a/templates/post.html
+++ b/templates/post.html
@@ -1,6 +1,6 @@
<address class="author">
- Posted on <time pubdate datetime="$cdate$" title="$hdate$">$hdate$</time> By
- <a rel="author" href="/">Skiletro</a>
+ Posted on <time pubdate datetime="$cdate$" title="$hdate$">$hdate$</time> by
+ <a rel="author" href="/">Skiletro</a>. Last modified $modified$.
</address>
<!-- prettier-ignore -->
<hr />