summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJJ2024-07-22 04:42:42 +0000
committerJJ2024-07-22 20:21:58 +0000
commit3c11f6cca5b73e188289ada66e7924b4b33e4f59 (patch)
tree2c410c7856d30985dfabf4319dcc6385a6872d1a
parent2a99a0556e17771181eb31b1c9f6fb6ed335158f (diff)
replace jekyll with hakyll
-rw-r--r--.gitignore4
-rw-r--r--404.html14
-rw-r--r--Gemfile5
-rw-r--r--_config.yml2
-rw-r--r--_includes/footer.html3
-rw-r--r--_includes/header.html13
-rw-r--r--_layouts/default.html13
-rw-r--r--_templates/default.html13
-rw-r--r--_templates/footer.html3
-rw-r--r--_templates/header.html13
-rw-r--r--_templates/main.html16
-rw-r--r--_templates/post.html17
-rw-r--r--index.html4
-rw-r--r--site.cabal10
-rw-r--r--site.hs62
-rw-r--r--stack.yaml4
16 files changed, 149 insertions, 47 deletions
diff --git a/.gitignore b/.gitignore
index ed90730..d2a7949 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
+_cache
_site
-Gemfile.lock
+.stack-work
+stack.yaml.lock
diff --git a/404.html b/404.html
index 2c82613..885663d 100644
--- a/404.html
+++ b/404.html
@@ -1,10 +1,10 @@
---
-layout: default
+layout: main
title: 404
---
- <meta http-equiv="refresh" content="0; URL=https://www.youtube.com/watch?v=dQw4w9WgXcQ"/>
- <link rel="canonical" href="https://www.youtube.com/watch?v=dQw4w9WgXcQ"/>
- {% include header.html %}
- <br>
- <h2 style="margin: 20px;">404</h2>
- <span>Page not found</span>
+<meta http-equiv="refresh" content="0; URL=https://www.youtube.com/watch?v=dQw4w9WgXcQ"/>
+<link rel="canonical" href="https://www.youtube.com/watch?v=dQw4w9WgXcQ"/>
+<style> main {text-align: center} footer {display: none} </style>
+<br>
+<h2 style="margin: 20px;">404</h2>
+<span>Page not found</span>
diff --git a/Gemfile b/Gemfile
deleted file mode 100644
index 7e303f2..0000000
--- a/Gemfile
+++ /dev/null
@@ -1,5 +0,0 @@
-source "https://rubygems.org"
-
-gem 'jekyll'
-
-gem "webrick", "~> 1.8"
diff --git a/_config.yml b/_config.yml
deleted file mode 100644
index d7040d8..0000000
--- a/_config.yml
+++ /dev/null
@@ -1,2 +0,0 @@
-title: my special corner of the web
-email: web@toki.la
diff --git a/_includes/footer.html b/_includes/footer.html
deleted file mode 100644
index 049de4a..0000000
--- a/_includes/footer.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<footer>
- <span><img src="https://toki.la/assets/copyleft.svg" width="12" height="12" title="https://en.wikipedia.org/wiki/Criticism_of_copyright" /> 2020-2024 </span>
-</footer>
diff --git a/_includes/header.html b/_includes/header.html
deleted file mode 100644
index 832e2ec..0000000
--- a/_includes/header.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<header>
- <h1>
- <a href="/">apropos</a>
- </h1>
- <nav>
- <a href="/about">about</a>
- <a href="/resume">resume</a>
- <a href="/notes">notes</a>
- <a href="/posts">posts</a>
- <a href="/writeups">writeups</a>
- <a href="https://wiki.toki.la">wiki</a>
- </nav>
-</header>
diff --git a/_layouts/default.html b/_layouts/default.html
deleted file mode 100644
index 6074f7a..0000000
--- a/_layouts/default.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <link rel="icon" type="image/jpg" href="assets/light.png">
- <link rel="stylesheet" href="css/style.css">
- <title> {{page.title}} </title>
-</head>
-<body>
- {{ content }}
-</body>
-</html>
diff --git a/_templates/default.html b/_templates/default.html
new file mode 100644
index 0000000..24da983
--- /dev/null
+++ b/_templates/default.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8"/>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+ <link rel="icon" type="image/jpg" href="/assets/light.png"/>
+ <link rel="stylesheet" href="/css/style.css"/>
+ <title> $title$ </title>
+</head>
+<body>
+$body$
+</body>
+</html>
diff --git a/_templates/footer.html b/_templates/footer.html
new file mode 100644
index 0000000..93b3dd7
--- /dev/null
+++ b/_templates/footer.html
@@ -0,0 +1,3 @@
+<footer>
+ <span><img src="/assets/copyleft.svg" width="12" height="12" title="https://en.wikipedia.org/wiki/Criticism_of_copyright" /> 2020-2024 </span>
+</footer>
diff --git a/_templates/header.html b/_templates/header.html
new file mode 100644
index 0000000..bfd4deb
--- /dev/null
+++ b/_templates/header.html
@@ -0,0 +1,13 @@
+<header>
+ <h1>
+ <a href="/">apropos</a>
+ </h1>
+ <nav>
+ <a href="/about">about</a>
+ <a href="/resume">resume</a>
+ <a href="/notes">notes</a>
+ <a href="/posts">posts</a>
+ <a href="/writeups">writeups</a>
+ <a href="https://wiki.toki.la">wiki</a>
+ </nav>
+</header>
diff --git a/_templates/main.html b/_templates/main.html
new file mode 100644
index 0000000..093c7da
--- /dev/null
+++ b/_templates/main.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8"/>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+ <link rel="icon" type="image/jpg" href="/assets/light.png"/>
+ <link rel="stylesheet" href="/css/style.css"/>
+ <title> $title$ </title>
+</head>
+<body>
+$partial("_templates/header.html")$
+<main>
+$body$
+</main>
+</body>
+</html>
diff --git a/_templates/post.html b/_templates/post.html
new file mode 100644
index 0000000..fca6aed
--- /dev/null
+++ b/_templates/post.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8"/>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+ <link rel="icon" type="image/jpg" href="/assets/light.png"/>
+ <link rel="stylesheet" href="/css/style.css"/>
+ <link rel="stylesheet" href="/writeups/css/style.css"/>
+ <title> $title$ </title>
+</head>
+<body>
+$partial("_templates/header.html")$
+<main>
+$body$
+</main>
+</body>
+</html>
diff --git a/index.html b/index.html
index f76ab69..8d2c961 100644
--- a/index.html
+++ b/index.html
@@ -1,10 +1,8 @@
---
-layout: default
+layout: main
title: my special corner of the web
---
-{% include header.html %}
-<main>
<div id="intro">
<img id="face" src="assets/compass.jpg"/>
<div id="profile">
diff --git a/site.cabal b/site.cabal
new file mode 100644
index 0000000..432ed8f
--- /dev/null
+++ b/site.cabal
@@ -0,0 +1,10 @@
+name: site
+version: 0.1
+build-type: Simple
+cabal-version: >= 1.10
+
+executable site
+ main-is: site.hs
+ build-depends: base == 4.*, hakyll == 4.16.*, pandoc == 3.*
+ ghc-options: -threaded -rtsopts -with-rtsopts=-N
+ default-language: Haskell2010
diff --git a/site.hs b/site.hs
new file mode 100644
index 0000000..47a385b
--- /dev/null
+++ b/site.hs
@@ -0,0 +1,62 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+import Hakyll hiding (pandocCompiler)
+import Text.Pandoc.Options
+import Text.Pandoc.Highlighting
+
+-- Pass custom options to the Pandoc compiler
+pandocCompiler :: Compiler (Item String)
+pandocCompiler =
+ let defaultExtensions = writerExtensions defaultHakyllWriterOptions
+ addedExtensions = extensionsFromList [Ext_lists_without_preceding_blankline]
+ removedExtensions = extensionsFromList [Ext_blank_before_header, Ext_blank_before_blockquote]
+ writerOptions = defaultHakyllWriterOptions {
+ writerExtensions = disableExtensions (defaultExtensions <> pandocExtensions <> addedExtensions) removedExtensions,
+ writerHTMLMathMethod = MathML,
+ writerHighlightStyle = Just zenburn
+ }
+ in pandocCompilerWith defaultHakyllReaderOptions writerOptions
+
+-- Loads the template specified in a post's metadata, if it exists
+loadLayoutTemplate :: Context String -> Item String -> Compiler (Item String)
+loadLayoutTemplate context item = do
+ field <- getMetadataField (itemIdentifier item) "layout"
+ case field of
+ Just path ->
+ let templatePath = "_templates/" ++ path ++ ".html" in
+ loadAndApplyTemplate (fromFilePath templatePath) context item
+ _ -> return item
+
+main :: IO ()
+main = hakyll $ do
+ -- Compile templates for future use
+ match "_templates/*" $ compile templateBodyCompiler
+
+ -- Detect whether HTML files are standalone or in need of a template
+ match ("**.html" .||. "**.htm") $ do
+ route idRoute
+ compile $ do
+ identifier <- getUnderlying
+ field <- getMetadataField identifier "layout"
+ case field of
+ Just _ -> pandocCompiler
+ Nothing -> getResourceBody
+ >>= loadLayoutTemplate defaultContext
+ >>= relativizeUrls
+
+ -- Match all other renderable files and apply their template, if it exists
+ match ("**.md" .||. "**.markdown") $ do
+ route $ setExtension "html"
+ compile $ pandocCompiler
+ >>= loadLayoutTemplate defaultContext
+ >>= relativizeUrls
+
+ -- Additionally copy non-HTML files verbatium
+ match ("**.md" .||. "**.markdown") $ version "raw" $ do
+ route idRoute
+ compile pandocCompiler
+
+ -- Copy all additional files verbatium
+ match "**" $ do
+ route idRoute
+ compile copyFileCompiler
diff --git a/stack.yaml b/stack.yaml
new file mode 100644
index 0000000..36d8e5b
--- /dev/null
+++ b/stack.yaml
@@ -0,0 +1,4 @@
+resolver: lts-22.30
+system-ghc: true
+packages:
+- .