Blog setup \o/
Reference: https://github.com/jaspervdj/jaspervdj/blob/master/src/Main.hs
This commit is contained in:
parent
bac1a26e2d
commit
4aa076cd61
|
@ -107,6 +107,22 @@ main {
|
|||
}
|
||||
}
|
||||
|
||||
.post-entry {
|
||||
.post-title {
|
||||
font-size: 120%
|
||||
}
|
||||
|
||||
.post-summary {
|
||||
font-style: italic;
|
||||
}
|
||||
}
|
||||
|
||||
hr {
|
||||
&.short-hr {
|
||||
max-width: 10em;
|
||||
}
|
||||
}
|
||||
|
||||
footer {
|
||||
p {
|
||||
display: block;
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<h1>~tito</h1>
|
||||
|
||||
<p>
|
||||
Hi! I'm Tito Sacchi, alias "tauroh", an Italian high school student trying to
|
||||
have fun while deciding which of my interests I'm willing to spend more time
|
||||
on in the forecoming years. I like maths, computers, classical piano,
|
||||
swimming, electric guitars, hiking, and a lot of other things that I'd be
|
||||
glad to share with someone else.
|
||||
</p>
|
||||
<p>
|
||||
Write me at
|
||||
<a href="mailto:tito@tilde.team" class="email">tito@tilde.team</a>. You can
|
||||
find some (hopefully) accurate contact information on the <a
|
||||
href="contact.html">contact page</a>.
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2>Recent posts</h3>
|
||||
$partial("templates/post-list.html")$
|
||||
<a href="posts.html">All posts...</a>
|
||||
|
||||
<!--
|
||||
vim: ts=2:sts=2:sw=2:et
|
||||
-->
|
15
index.md
15
index.md
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
title: Home
|
||||
---
|
||||
|
||||
# Hi! Welcome to my website.
|
||||
|
||||
I'm Tito Sacchi, an Italian guy trying to have fun while deciding which of my
|
||||
interests I'm willing to spend more time on in the forecoming years. I like
|
||||
maths, computers, classical piano, swimming, electric guitars, hiking, and a
|
||||
lot of other things that I'd be glad to share with someone else.
|
||||
|
||||
Write me at <tito@tilde.team>. You can find some (hopefully) accurate contact
|
||||
information on the [contact page](contact.html).
|
||||
|
||||
[comment]: # vim: ts=2:sts=2:sw=2:et:nojoinspaces
|
57
site.hs
57
site.hs
|
@ -1,5 +1,9 @@
|
|||
{-# LANGUAGE LambdaCase #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
import Control.Monad.State
|
||||
import Hakyll
|
||||
import Text.Pandoc.Extensions
|
||||
import Text.Pandoc.Options
|
||||
|
||||
main :: IO ()
|
||||
main = hakyllWith config $ do
|
||||
|
@ -13,6 +17,20 @@ main = hakyllWith config $ do
|
|||
>>= withItemBody (unixFilter "sass" ["--stdin"])
|
||||
>>= return . fmap compressCss
|
||||
|
||||
tags <- buildTags "posts/*" (fromCapture "tags/*.html")
|
||||
|
||||
match "index.html" $ do
|
||||
route $ setExtension "html"
|
||||
compile $ do
|
||||
posts <- loadAll "posts/*" >>= recentFirst >>= pure . (take 5)
|
||||
let ctx = listField "posts" (postCtx tags) (pure posts)
|
||||
<> constField "title" "Home"
|
||||
<> defaultContext
|
||||
getResourceBody
|
||||
>>= applyAsTemplate ctx
|
||||
>>= loadAndApplyTemplate "templates/default.html" ctx
|
||||
>>= relativizeUrls
|
||||
|
||||
match "*.md" $ do
|
||||
route $ setExtension "html"
|
||||
compile $ pandocCompiler
|
||||
|
@ -21,6 +39,38 @@ main = hakyllWith config $ do
|
|||
|
||||
match "templates/*" $ compile templateBodyCompiler
|
||||
|
||||
match "posts/*.md" $ do
|
||||
let ctx = postCtx tags
|
||||
route $ setExtension "html"
|
||||
compile $ pandocCompiler
|
||||
>>= loadAndApplyTemplate "templates/post.html" ctx
|
||||
>>= loadAndApplyTemplate "templates/default.html" ctx
|
||||
>>= relativizeUrls
|
||||
|
||||
tagsRules tags $ \tag pattern -> do
|
||||
route $ idRoute
|
||||
compile $ do
|
||||
posts <- loadAll pattern >>= recentFirst
|
||||
let ctx = constField "title" ("Posts tagged " ++ tag)
|
||||
<> listField "posts" (postCtx tags) (pure posts)
|
||||
<> defaultContext
|
||||
makeItem ""
|
||||
>>= loadAndApplyTemplate "templates/posts.html" ctx
|
||||
>>= loadAndApplyTemplate "templates/default.html" ctx
|
||||
>>= relativizeUrls
|
||||
|
||||
create ["posts.html"] $ do
|
||||
route idRoute
|
||||
compile $ do
|
||||
posts <- loadAll "posts/*" >>= recentFirst
|
||||
let ctx = constField "title" "Posts"
|
||||
<> listField "posts" (postCtx tags) (pure posts)
|
||||
<> defaultContext
|
||||
makeItem ""
|
||||
>>= loadAndApplyTemplate "templates/posts.html" ctx
|
||||
>>= loadAndApplyTemplate "templates/default.html" ctx
|
||||
>>= relativizeUrls
|
||||
|
||||
config :: Configuration
|
||||
config = defaultConfiguration {
|
||||
deployCommand = "rsync -avP --delete \
|
||||
|
@ -28,4 +78,11 @@ config = defaultConfiguration {
|
|||
\ _site/ tito@tilde.team:~/public_html"
|
||||
}
|
||||
|
||||
postCtx :: Tags -> Context String
|
||||
postCtx tags = mconcat
|
||||
[ dateField "date" "%B %e, %Y"
|
||||
, tagsField "tags" tags
|
||||
, defaultContext
|
||||
]
|
||||
|
||||
-- vim: ts=4:sts=4:sw=4:et
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@300;400&display=swap" rel="stylesheet">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<link rel="stylesheet" href="/css/style.css">
|
||||
<title>~tito • $title$</title>
|
||||
<meta name="description" content="tito's tilde page">
|
||||
</head>
|
||||
|
@ -22,14 +22,14 @@
|
|||
<div class="container">
|
||||
<header class="row">
|
||||
<div class="title">
|
||||
<h1><a href=".">/home/tito</a></h1>
|
||||
<h1><a href="/">/home/tito</a></h1>
|
||||
</div>
|
||||
</header>
|
||||
<nav class="row">
|
||||
<ul>
|
||||
<li><a href="about_me.html">/about_me</a></li>
|
||||
<li><a href="contacts.html">/contacts</a></li>
|
||||
<li><a href="cv.html">/cv</a></li>
|
||||
<li><a href="/about_me.html">/about_me</a></li>
|
||||
<li><a href="/contacts.html">/contacts</a></li>
|
||||
<li><a href="/posts.html">/archive</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<main class="row">
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
$for(posts)$
|
||||
<div class="post-entry">
|
||||
<a class="post-title" href="$url$">
|
||||
$if(displaytitle)$
|
||||
$displaytitle$
|
||||
$else$
|
||||
$title$
|
||||
$endif$
|
||||
</a>
|
||||
$partial("templates/post-meta.html")$
|
||||
</div>
|
||||
$sep$
|
||||
<hr class="short-hr">
|
||||
$endfor$
|
||||
<!--
|
||||
vim: ts=2:sts=2:sw=2:et
|
||||
-->
|
|
@ -0,0 +1,10 @@
|
|||
<p class="post-meta">
|
||||
Posted on $date$ $if(tags)$ • Tags: $tags$ $endif$
|
||||
$if(summary)$
|
||||
<br>
|
||||
▶︎ <span class="post-summary">$summary$</span> ◀︎
|
||||
$endif$
|
||||
</p>
|
||||
<!--
|
||||
vim: ts=2:sts=2:sw=2:et
|
||||
-->
|
|
@ -0,0 +1,12 @@
|
|||
$if(displaytitle)$
|
||||
<h1>$displaytitle$</h1>
|
||||
$else$
|
||||
$if(title)$
|
||||
<h1>$title$</h1>
|
||||
$endif$
|
||||
$endif$
|
||||
$partial("templates/post-meta.html")$
|
||||
$body$
|
||||
<!--
|
||||
vim: ts=2:sts=2:sw=2:et
|
||||
-->
|
|
@ -0,0 +1,5 @@
|
|||
<h1>$title$</h1>
|
||||
$partial("templates/post-list.html")$
|
||||
<!--
|
||||
vim: ts=2:sts=2:sw=2:et
|
||||
-->
|
Loading…
Reference in New Issue