diff --git a/css/default.css b/css/default.css index 38f1286..c4b4b38 100644 --- a/css/default.css +++ b/css/default.css @@ -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; + } } diff --git a/posts/2022-12-05-placeholder.org b/posts/2022-12-05-placeholder.org index f102062..f9e9183 100644 --- a/posts/2022-12-05-placeholder.org +++ b/posts/2022-12-05-placeholder.org @@ -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 #+END_EXPORT + +** how +loda hai kya diff --git a/posts/2022-12-06-placeholder2.org b/posts/2022-12-06-placeholder2.org new file mode 100644 index 0000000..cc87ff6 --- /dev/null +++ b/posts/2022-12-06-placeholder2.org @@ -0,0 +1,18 @@ +--- +title: alo +tags: amaang +enabletoc: true +--- + +#+OPTIONS: toc:nil + +* The + +alo, i am a. + +#+BEGIN_EXPORT HTML + +#+END_EXPORT + +** how +loda hai kya diff --git a/scripts/default.js b/scripts/default.js deleted file mode 100644 index e69de29..0000000 diff --git a/src/site.hs b/src/site.hs index 26e2f16..01068f5 100644 --- a/src/site.hs +++ b/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 diff --git a/templates/post-preview-list.html b/templates/post-preview-list.html index 5a13743..6833582 100644 --- a/templates/post-preview-list.html +++ b/templates/post-preview-list.html @@ -1,6 +1,6 @@ -