add stylesheet for syntax highlighting and add toc

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2022-05-13 07:41:43 +05:30
parent 0e6d6d79a2
commit 0c4333e325
15 changed files with 223 additions and 281 deletions

View File

@@ -9,20 +9,80 @@
font-style: normal; font-style: normal;
} }
@import url("https://cdn.jsdelivr.net/npm/@xz/fonts@1/serve/cascadia-code.min.css");
:root {
--yellow: #b58900;
--orange: #cb4b16;
--red: #dc322f;
--magenta: #d33682;
--violet: #6c71c4;
--blue: #268bd2;
--cyan: #2aa198;
--green: #859900;
--fg0: #93a1a1;
--fg1: #839496;
--fg2: #657b83;
--fg3: #586e75;
--fg4: #073642;
--fg5: #002b36;
--bg0: #fdf6e3 ;
--bg1: #eee8d5;
--dark: #002b36;
--light: #fdf6e3;
}
@media (prefers-color-scheme: dark) {
:root {
--bg0: #073642;
--bg1: #002b36;
--fg5: #fdf6e3 ;
--fg4: #eee8d5;
--fg3: #93a1a1;
--fg2: #839496;
--fg1: #657b83;
--fg0: #586e75;
}
}
html { html {
font-size: 62.5%; font-size: 62.5%;
background-color: var(--bg0);
color: var(--fg2);
} }
body { body {
font-size: 1.6rem; font-size: 1.6rem;
color: #000; word-wrap: break-word;
}
h1, h2, h3 {
color: var(--fg3);
} }
header { header {
border-bottom: 0.2rem solid #000; border-bottom: 0.2rem solid var(--magenta);
margin: 4.2rem 0; margin: 4.2rem 0;
} }
main a, footer a {
color: var(--blue);
}
main a:hover, footer a:hover {
color: var(--light);
background: var(--blue);
}
a {
text-decoration: none;
}
a:hover {
transition-duration: 0.1s;
}
nav { nav {
text-align: center; text-align: center;
margin: 0 auto 3rem; margin: 0 auto 3rem;
@@ -31,22 +91,22 @@ nav {
nav a { nav a {
font-size: 1.8rem; font-size: 1.8rem;
font-weight: bold; font-weight: bold;
color: black; color: var(--cyan);
text-decoration: none;
text-transform: uppercase; text-transform: uppercase;
padding: 0.5rem;
} }
nav a:hover { nav a:hover {
color: pink; background: var(--cyan);
color: var(--dark);
} }
footer { footer {
margin-top: 3rem; margin-top: 3rem;
padding: 1.2rem 0; padding: 1.2rem 0;
border-top: 0.2rem solid #000; border-top: 0.2rem solid var(--magenta);
font-size: 1.2rem; font-size: 1.2rem;
color: #555; color: var(--fg0);
} }
h1 { h1 {
@@ -57,10 +117,15 @@ h2 {
font-size: 2rem; font-size: 2rem;
} }
article .header { .post-title {
text-align: center;
color: var(--fg5) !important;
}
article .post-header {
font-size: 1.4rem; font-size: 1.4rem;
font-style: italic; font-style: italic;
color: #555; color: var(--fg0);
} }
.logo { .logo {
@@ -74,23 +139,41 @@ article .header {
.logo a { .logo a {
font-weight: bold; font-weight: bold;
font-family: "Monoid Bold"; font-family: "Monoid Bold", sans-serif;
font-size: 3rem; font-size: 3rem;
color: #000; color: var(--green);
text-decoration: none; text-decoration: none;
} }
.subdomains { article > section {
list-style-type: none; overflow: auto;
} }
.subdomains li { .toc {
display: inline-block; padding: 2rem;
float: right;
border-radius: 1rem;
background: var(--bg1);
} }
.subdomains img { .post-teaser > .toc {
width: 30px; display: none;
height: 30px; }
code {
font-family: 'Cascadia Code', sans-serif;
}
code {
border-radius: 0.2rem;
background: var(--bg1);
}
pre {
padding: 2rem;
border-radius: 1rem;
background: var(--bg1);
overflow: scroll;
} }
@media (max-width: 319px) { @media (max-width: 319px) {

31
css/highlight.css Normal file
View File

@@ -0,0 +1,31 @@
/* Solarized theme for Pandoc Code */
pre code { color: var(--fg2); }
code span.kw { color: var(--green); } /* Keyword */
code span.dt { color: var(--yellow); } /* DataType */
code span.dv { color: var(--cyan); } /* DecVal */
code span.bn { color: var(--cyan); } /* BaseN */
code span.fl { color: var(--cyan); } /* Float */
code span.ch { color: var(--cyan); } /* Char */
code span.st { color: var(--cyan); } /* String */
code span.co { color: var(--fg0); font-style: italic; } /* Comment */
code span.ot { color: var(--blue); } /* Other */
code span.al { color: var(--red); } /* Alert */
code span.fu { color: var(--blue); } /* Function */
code span.cn { color: var(--cyan); } /* Constant */
code span.sc { color: var(--red); } /* SpecialChar */
code span.vs { color: var(--fg2); } /* VerbatimString */
code span.ss { color: var(--red); } /* SpecialString */
code span.im { color: var(--fg2); } /* Import */
code span.va { color: var(--blue); } /* Variable */
code span.cf { color: var(--green); } /* ControlFlow */
code span.op { color: var(--green); } /* Operator */
code span.bu { color: var(--fg2); } /* BuiltIn */
code span.ex { color: var(--fg2); } /* Extension */
code span.pp { color: var(--orange); } /* Preprocessor */
code span.at { color: var(--fg2); } /* Attribute */
code span.er { color: var(--red); } /* Error */
code span.wa { color: var(--orange); font-style: italic; } /* Warning */
code span.do { color: var(--fg0); font-style: italic; } /* Documentation */
code span.an { color: var(--fg0); font-style: italic; } /* Annotation */
code span.cv { color: var(--fg0); font-style: italic; } /* CommentVar */
code span.in { color: var(--fg0); font-weight:normal; font-style: normal; } /* Information */

View File

@@ -18,7 +18,7 @@
LANG = "en_US.UTF-8"; LANG = "en_US.UTF-8";
}; };
site = pkgs.haskellPackages.callCabal2nix "nattopages" ./. { }; site = pkgs.haskellPackages.callCabal2nix "nattopages" ./src { };
nattopages = pkgs.stdenv.mkDerivation { nattopages = pkgs.stdenv.mkDerivation {
name = "nattopages"; name = "nattopages";
src = ./.; src = ./.;
@@ -27,7 +27,7 @@
buildPhase = (pkgs.lib.concatStringsSep "\n" vars ) + '' buildPhase = (pkgs.lib.concatStringsSep "\n" vars ) + ''
log=$(site build) log=$(site build)
mkdir -p $out mkdir -p $out
cp -r _site/* $out cp -r \_site/* $out
''; '';
}; };
in in

View File

@@ -4,10 +4,5 @@ home: true
--- ---
<h2>Welcome</h2> <h2>Welcome</h2>
$partial("templates/post-preview-list.html")$
<p>These are some pages by natto:</p> <p>Find more in the <a href="/archive.html">archives</a>.</p>
<h2>Posts</h2>
$partial("templates/post-list.html")$
<p>…or you can find more in the <a href="/archive.html">archives</a>.</p>

View File

@@ -1,227 +1,13 @@
--- ---
title: alo title: alo
tags: amaang tags: amaang, shararati
--- ---
this is so true
* a
3
* a * The
* a
* a alo, i am a.
* a
* a #+BEGIN_EXPORT HTML
* a <!--more-->
* a #+END_EXPORT
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
* a
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3

0
scripts/default.js Normal file
View File

View File

@@ -8,5 +8,7 @@ executable site
main-is: site.hs main-is: site.hs
build-depends: base == 4.* build-depends: base == 4.*
, hakyll == 4.15.* , hakyll == 4.15.*
, pandoc == 2.*
, text == 1.*
ghc-options: -threaded -rtsopts -with-rtsopts=-N ghc-options: -threaded -rtsopts -with-rtsopts=-N
default-language: Haskell2010 default-language: Haskell2010

View File

@@ -1,9 +1,15 @@
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
import Data.Functor.Identity (runIdentity)
import Data.Text (Text)
import qualified Data.Text as T
import Hakyll import Hakyll
import Text.Pandoc (WriterOptions (writerHighlightStyle, writerNumberSections, writerTOCDepth, writerTableOfContents, writerTemplate))
import Text.Pandoc.Templates (Template, compileTemplate)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
main :: IO () main :: IO ()
main = hakyllWith config $ do main = hakyllWith config $ do
match "images/*" $ do match "images/*" $ do
@@ -39,25 +45,12 @@ main = hakyllWith config $ do
>>= loadAndApplyTemplate "templates/default.html" tagCtx >>= loadAndApplyTemplate "templates/default.html" tagCtx
>>= relativizeUrls >>= relativizeUrls
create ["archive/tags.html"] $ do
route idRoute
compile $ do
let tagListCtx =
field "tags" (\_ -> renderTagList tags)
<> constField "title" "Tag List"
<> defaultCtx
makeItem ""
>>= loadAndApplyTemplate "templates/tags.html" tagListCtx
>>= loadAndApplyTemplate "templates/default.html" tagListCtx
>>= relativizeUrls
match "posts/*org" $ do match "posts/*org" $ do
route $ setExtension "html" route $ setExtension "html"
compile $ compile $
pandocCompiler pandocCompilerWith defaultHakyllReaderOptions writerOptions
>>= saveSnapshot "content" >>= saveSnapshot "content"
>>= loadAndApplyTemplate "templates/post.html" (postCtx tags) >>= loadAndApplyTemplate "templates/post.html" (postCtx tags <> teaserField "teaser" "content")
>>= loadAndApplyTemplate "templates/default.html" (postCtx tags) >>= loadAndApplyTemplate "templates/default.html" (postCtx tags)
>>= relativizeUrls >>= relativizeUrls
@@ -68,6 +61,7 @@ main = hakyllWith config $ do
let archiveCtx = let archiveCtx =
listField "posts" (postCtx tags) (return posts) listField "posts" (postCtx tags) (return posts)
<> constField "title" "Archives" <> constField "title" "Archives"
<> field "tags" (\_ -> renderTagList tags)
<> defaultCtx <> defaultCtx
makeItem "" makeItem ""
@@ -78,7 +72,7 @@ main = hakyllWith config $ do
match "index.html" $ do match "index.html" $ do
route idRoute route idRoute
compile $ do compile $ do
posts <- recentFirst =<< loadAll "posts/*" posts <- fmap (take 10) . recentFirst =<< loadAllSnapshots "posts/*" "content"
let indexCtx = let indexCtx =
listField "posts" (postCtx tags) (return posts) listField "posts" (postCtx tags) (return posts)
<> defaultCtx <> defaultCtx
@@ -88,6 +82,10 @@ main = hakyllWith config $ do
>>= loadAndApplyTemplate "templates/default.html" indexCtx >>= loadAndApplyTemplate "templates/default.html" indexCtx
>>= relativizeUrls >>= relativizeUrls
match "images/*" $ do
route idRoute
compile copyFileCompiler
match "templates/*" $ compile templateBodyCompiler match "templates/*" $ compile templateBodyCompiler
config :: Configuration config :: Configuration
@@ -103,7 +101,9 @@ config =
postCtx :: Tags -> Context String postCtx :: Tags -> Context String
postCtx tags = postCtx tags =
tagsField "tags" tags tagsField "tags" tags
-- <> teaserFieldWithSeparator "((.tease.))" "teaser" "content"
<> dateField "date" "%B %e, %Y" <> dateField "date" "%B %e, %Y"
<> teaserField "teaser" "content"
<> defaultCtx <> defaultCtx
defaultCtx :: Context String defaultCtx :: Context String
@@ -125,3 +125,22 @@ defaultCtx =
where where
mkItem :: a -> Item a mkItem :: a -> Item a
mkItem a = Item {itemIdentifier = "subdomain", itemBody = a} mkItem a = Item {itemIdentifier = "subdomain", itemBody = a}
writerOptions :: WriterOptions
writerOptions =
defaultHakyllWriterOptions
{ writerNumberSections = True,
writerTableOfContents = True,
writerTOCDepth = 2,
writerTemplate = Just tocTemplate
}
tocTemplate :: Text.Pandoc.Templates.Template Text
tocTemplate =
either error id . runIdentity . compileTemplate "" $
T.unlines
[ "<div class=\"toc\"><div class=\"toc-header\">Table of Contents</div>",
"$toc$",
"</div>",
"$body$"
]

View File

@@ -1,3 +1,7 @@
<p><a href="/archive/tags.html">Tags</a></p> <p>
Here you can find all my previous posts: <h3> Here you can find all my previous posts: </h3>
</p>
$partial("templates/post-list.html")$ $partial("templates/post-list.html")$
<h3>Tags</strong></h3>
<div class="tags">$tags$</div>

View File

@@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>nattopages - $title$</title> <title>nattopages - $title$</title>
<link rel="stylesheet" href="/css/default.css" /> <link rel="stylesheet" href="/css/default.css" />
<link rel="stylesheet" href="/css/highlight.css" />
</head> </head>
<body> <body>
<header> <header>
@@ -28,11 +29,13 @@
<a href="https://git.weirdnatto.in/natto1784/nattopages">Source</a> available under MIT License<br> <a href="https://git.weirdnatto.in/natto1784/nattopages">Source</a> available under MIT License<br>
Site proudly generated by Site proudly generated by
<a href="http://jaspervdj.be/hakyll">Hakyll</a><br> <a href="http://jaspervdj.be/hakyll">Hakyll</a><br>
PGP Fingerprint: 53EC 089E F230 E47A 83BA 8F81 9594 9BD4 B853 F559 53EC 089E F230 E47A 83BA 8F81 9594 9BD4 B853 F559
<ul class="subdomains"> <ul class="subdomains" style="list-style-type: none;">
$for(subdomains)$ $for(subdomains)$
<li> <li style="display: inline-block;">
<a href="https://$name$.$domain$"> <img src="/images/logos/$name$.png" alt="https://$name$.$domain$"/> </a> <a href="https://$name$.$domain$">
<img src="/images/logos/$name$.png" alt="https://$name$.$domain$" width="30" height="30"/>
</a>
</li> </li>
$endfor$ $endfor$
</ul> </ul>

View File

@@ -1,6 +1,6 @@
<ul> <ul>
$for(posts)$ $for(posts)$
<li> <li class="post-item">
<a href="$url$">$title$</a> - $date$ <a href="$url$">$title$</a> - $date$
</li> </li>
$endfor$ $endfor$

View File

@@ -0,0 +1,23 @@
<ul>
$for(posts)$
<li class="post-item post-preview-item" style="list-style-type: none;" >
<article>
<h1 class="post-title">$title$</h1>
<div class="post-header">
<div class="post-date" >
Posted $date$
</div>
<div class="tags" >
$if(tags)$
Tags: $tags$
$endif$
</div>
</div>
<div class="post-teaser">
$teaser$
</div>
<a href="$url$">Read more</a>
</article>
</li>
$endfor$
</ul>

View File

@@ -1,5 +1,6 @@
<article> <article>
<section class="header"> <h1 class="post-title">$title$</h1>
<section class="post-header">
Posted on $date$ Posted on $date$
$if(author)$ $if(author)$
by $author$ by $author$
@@ -8,6 +9,7 @@
Tags: $tags$ Tags: $tags$
$endif$ $endif$
</section> </section>
<hr>
<section> <section>
$body$ $body$
</section> </section>

View File

@@ -1,2 +1,2 @@
Here are all the posts marked with tag $tag$: Here are all the posts marked with tag <strong style="font-size: 3rem;">$tag$</strong>:
$partial("templates/post-list.html")$ $partial("templates/post-list.html")$

View File

@@ -1,6 +0,0 @@
$if(tags)$
Here is a list of all the tags:
<div class="tags"><p>$tags$</p></div>
$else$
There are no tags
$endif$