Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dummyx committed Aug 12, 2022
0 parents commit f96cacb
Show file tree
Hide file tree
Showing 10 changed files with 285 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_cache
_site
dist-newstyle
11 changes: 11 additions & 0 deletions blog.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: blog
version: 0.1.0.0
build-type: Simple
cabal-version: >= 1.10

executable site
main-is: site.hs
build-depends: base == 4.*
, hakyll == 4.15.*
ghc-options: -threaded -rtsopts -with-rtsopts=-N
default-language: Haskell2010
141 changes: 141 additions & 0 deletions css/default.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
html {
font-size: 62.5%;
}

body {
font-size: 1.6rem;
color: #000;
}

header {
border-bottom: 0.2rem solid #000;
}

nav {
text-align: right;
}

nav a {
font-size: 1.8rem;
font-weight: bold;
color: black;
text-decoration: none;
text-transform: uppercase;
}

footer {
margin-top: 3rem;
padding: 1.2rem 0;
border-top: 0.2rem solid #000;
font-size: 1.2rem;
color: #555;
}

h1 {
font-size: 2.4rem;
}

h2 {
font-size: 2rem;
}

article .header {
font-size: 1.4rem;
font-style: italic;
color: #555;
}

.logo a {
font-weight: bold;
color: #000;
text-decoration: none;
}

@media (max-width: 319px) {
body {
width: 90%;
margin: 0;
padding: 0 5%;
}
header {
margin: 4.2rem 0;
}
nav {
margin: 0 auto 3rem;
text-align: center;
}
footer {
text-align: center;
}
.logo {
text-align: center;
margin: 1rem auto 3rem;
}
.logo a {
font-size: 2.4rem;
}
nav a {
display: block;
line-height: 1.6;
}
}

@media (min-width: 320px) {
body {
width: 90%;
margin: 0;
padding: 0 5%;
}
header {
margin: 4.2rem 0;
}
nav {
margin: 0 auto 3rem;
text-align: center;
}
footer {
text-align: center;
}
.logo {
text-align: center;
margin: 1rem auto 3rem;
}
.logo a {
font-size: 2.4rem;
}
nav a {
display: inline;
margin: 0 0.6rem;
}
}

@media (min-width: 640px) {
body {
width: 60rem;
margin: 0 auto;
padding: 0;
}
header {
margin: 0 0 3rem;
padding: 1.2rem 0;
}
nav {
margin: 0;
text-align: right;
}
nav a {
margin: 0 0 0 1.2rem;
display: inline;
}
footer {
text-align: right;
}
.logo {
margin: 0;
text-align: left;
}
.logo a {
float: left;
font-size: 1.8rem;
}
}
Binary file added images/haskell-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: No Ink Involved
---

<h2>Ironically, there is no ink involved with this site.</h2>

<img src="/images/haskell-logo.png" style="float: right; margin: 10px;" />

<h2>Posts</h2>
$partial("templates/post-list.html")$

66 changes: 66 additions & 0 deletions site.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
import Data.Monoid (mappend)
import Hakyll


--------------------------------------------------------------------------------
main :: IO ()
main = hakyll $ do
match "images/*" $ do
route idRoute
compile copyFileCompiler

match "css/*" $ do
route idRoute
compile compressCssCompiler

{- match (fromList ["about.rst", "contact.markdown"]) $ do
route $ setExtension "html"
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls -}

match "posts/*" $ do
route $ setExtension "html"
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/post.html" postCtx
>>= loadAndApplyTemplate "templates/default.html" postCtx
>>= relativizeUrls

{- create ["archive.html"] $ do
route idRoute
compile $ do
posts <- recentFirst =<< loadAll "posts/*"
let archiveCtx =
listField "posts" postCtx (return posts) `mappend`
constField "title" "Archives" `mappend`
defaultContext
makeItem ""
>>= loadAndApplyTemplate "templates/archive.html" archiveCtx
>>= loadAndApplyTemplate "templates/default.html" archiveCtx
>>= relativizeUrls -}


match "index.html" $ do
route idRoute
compile $ do
posts <- recentFirst =<< loadAll "posts/*"
let indexCtx =
listField "posts" postCtx (return posts) `mappend`
defaultContext

getResourceBody
>>= applyAsTemplate indexCtx
>>= loadAndApplyTemplate "templates/default.html" indexCtx
>>= relativizeUrls

match "templates/*" $ compile templateBodyCompiler


--------------------------------------------------------------------------------
postCtx :: Context String
postCtx =
dateField "date" "%B %e, %Y" `mappend`
defaultContext
2 changes: 2 additions & 0 deletions templates/archive.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Here you can find all my previous posts:
$partial("templates/post-list.html")$
33 changes: 33 additions & 0 deletions templates/default.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My Hakyll Blog - $title$</title>
<link rel="stylesheet" href="/css/default.css" />
</head>
<body>
<header>
<div class="logo">
<a href="/">My Hakyll Blog</a>
</div>
<nav>
<a href="/">Home</a>
<a href="/about.html">About</a>
<a href="/contact.html">Contact</a>
<a href="/archive.html">Archive</a>
</nav>
</header>

<main role="main">
<h1>$title$</h1>
$body$
</main>

<footer>
Site proudly generated by
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</footer>
</body>
</html>
7 changes: 7 additions & 0 deletions templates/post-list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<ul>
$for(posts)$
<li>
<a href="$url$">$title$</a> - $date$
</li>
$endfor$
</ul>
11 changes: 11 additions & 0 deletions templates/post.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<article>
<section class="header">
Posted on $date$
$if(author)$
by $author$
$endif$
</section>
<section>
$body$
</section>
</article>

0 comments on commit f96cacb

Please sign in to comment.