add optional toc and numbering fields
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
@@ -117,6 +117,16 @@ h2 {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.post-preview-item {
|
||||
list-style-type: none;
|
||||
padding: 2rem;
|
||||
border: 0.5rem dotted var(--violet);
|
||||
}
|
||||
|
||||
.post-preview-item:not(:last-child) {
|
||||
margin-bottom: 3rem;
|
||||
}
|
||||
|
||||
.post-title {
|
||||
text-align: center;
|
||||
color: var(--fg5) !important;
|
||||
@@ -149,13 +159,6 @@ article > section {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.toc {
|
||||
padding: 2rem;
|
||||
float: right;
|
||||
border-radius: 1rem;
|
||||
background: var(--bg1);
|
||||
}
|
||||
|
||||
.post-teaser > .toc {
|
||||
display: none;
|
||||
}
|
||||
@@ -176,6 +179,13 @@ pre {
|
||||
overflow: scroll;
|
||||
}
|
||||
|
||||
.toc {
|
||||
background: var(--bg1);
|
||||
border-radius: 1rem;
|
||||
float: right;
|
||||
max-width: 40%;
|
||||
}
|
||||
|
||||
@media (max-width: 319px) {
|
||||
body {
|
||||
width: 90%;
|
||||
@@ -189,10 +199,8 @@ pre {
|
||||
display: block;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.sticky {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
background: white;
|
||||
.toc {
|
||||
padding: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,6 +217,9 @@ pre {
|
||||
display: inline;
|
||||
margin: 0 0.6rem;
|
||||
}
|
||||
.toc {
|
||||
padding: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 640px) {
|
||||
@@ -224,4 +235,7 @@ pre {
|
||||
footer {
|
||||
text-align: right;
|
||||
}
|
||||
.toc {
|
||||
padding: 2rem;
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,10 @@
|
||||
---
|
||||
title: alo
|
||||
tags: amaang, shararati
|
||||
enabletoc: true
|
||||
---
|
||||
|
||||
#+OPTIONS: toc:nil
|
||||
|
||||
* The
|
||||
|
||||
@@ -11,3 +13,6 @@ alo, i am a.
|
||||
#+BEGIN_EXPORT HTML
|
||||
<!--more-->
|
||||
#+END_EXPORT
|
||||
|
||||
** how
|
||||
loda hai kya
|
||||
|
18
posts/2022-12-06-placeholder2.org
Normal file
18
posts/2022-12-06-placeholder2.org
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
title: alo
|
||||
tags: amaang
|
||||
enabletoc: true
|
||||
---
|
||||
|
||||
#+OPTIONS: toc:nil
|
||||
|
||||
* The
|
||||
|
||||
alo, i am a.
|
||||
|
||||
#+BEGIN_EXPORT HTML
|
||||
<!--more-->
|
||||
#+END_EXPORT
|
||||
|
||||
** how
|
||||
loda hai kya
|
15
src/site.hs
15
src/site.hs
@@ -7,6 +7,7 @@ import qualified Data.Text as T
|
||||
import Hakyll
|
||||
import Text.Pandoc (WriterOptions (writerHighlightStyle, writerNumberSections, writerTOCDepth, writerTableOfContents, writerTemplate))
|
||||
import Text.Pandoc.Templates (Template, compileTemplate)
|
||||
import Data.Maybe (isJust)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@@ -47,8 +48,12 @@ main = hakyllWith config $ do
|
||||
|
||||
match "posts/*org" $ do
|
||||
route $ setExtension "html"
|
||||
compile $
|
||||
pandocCompilerWith defaultHakyllReaderOptions writerOptions
|
||||
compile $ do
|
||||
identifier <- getUnderlying
|
||||
toc <- getMetadataField identifier "enabletoc"
|
||||
numbering <- getMetadataField identifier "enablenumbering"
|
||||
let writerOptions' = maybe defaultHakyllWriterOptions (const $ writerOptions $ isJust numbering) toc
|
||||
pandocCompilerWith defaultHakyllReaderOptions writerOptions'
|
||||
>>= saveSnapshot "content"
|
||||
>>= loadAndApplyTemplate "templates/post.html" (postCtx tags <> teaserField "teaser" "content")
|
||||
>>= loadAndApplyTemplate "templates/default.html" (postCtx tags)
|
||||
@@ -126,10 +131,10 @@ defaultCtx =
|
||||
mkItem :: a -> Item a
|
||||
mkItem a = Item {itemIdentifier = "subdomain", itemBody = a}
|
||||
|
||||
writerOptions :: WriterOptions
|
||||
writerOptions =
|
||||
writerOptions :: Bool -> WriterOptions
|
||||
writerOptions withNumbering =
|
||||
defaultHakyllWriterOptions
|
||||
{ writerNumberSections = True,
|
||||
{ writerNumberSections = withNumbering,
|
||||
writerTableOfContents = True,
|
||||
writerTOCDepth = 2,
|
||||
writerTemplate = Just tocTemplate
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<ul>
|
||||
<ul class="post-preview-item-list">
|
||||
$for(posts)$
|
||||
<li class="post-item post-preview-item" style="list-style-type: none;" >
|
||||
<li class="post-preview-item" >
|
||||
<article>
|
||||
<h1 class="post-title">$title$</h1>
|
||||
<div class="post-header">
|
||||
|
Reference in New Issue
Block a user