Browse Source

Fix post listings & add comments

Amélia Liao 3 years ago
parent
commit
3ac48903e7
2 changed files with 19 additions and 8 deletions
  1. +3
    -3
      site.hs
  2. +16
    -5
      templates/post.html

+ 3
- 3
site.hs View File

@ -196,7 +196,7 @@ main = (*>) (setEnv "AMC_LIBRARY_PATH" "/usr/lib/amuletml/lib/") $ hakyllWith co
create ["archive.html"] $ do create ["archive.html"] $ do
route idRoute route idRoute
compile $ do compile $ do
posts <- recentFirst =<< loadAll "posts/*"
posts <- recentFirst =<< loadAll "pages/posts/*"
let archiveCtx = let archiveCtx =
listField "posts" postCtx (return posts) <> listField "posts" postCtx (return posts) <>
constField "title" "Archives" <> constField "title" "Archives" <>
@ -209,7 +209,7 @@ main = (*>) (setEnv "AMC_LIBRARY_PATH" "/usr/lib/amuletml/lib/") $ hakyllWith co
match "pages/*.html" $ do match "pages/*.html" $ do
route $ gsubRoute "pages/" (const "") route $ gsubRoute "pages/" (const "")
compile $ do compile $ do
posts <- fmap (take 5) . recentFirst =<< loadAll "posts/*"
posts <- fmap (take 5) . recentFirst =<< loadAll "pages/posts/*"
let indexCtx = let indexCtx =
listField "posts" postCtx (return posts) <> listField "posts" postCtx (return posts) <>
constField "title" "Home" <> constField "title" "Home" <>
@ -241,7 +241,7 @@ main = (*>) (setEnv "AMC_LIBRARY_PATH" "/usr/lib/amuletml/lib/") $ hakyllWith co
route idRoute route idRoute
compile $ do compile $ do
let feedCtx = postCtx <> bodyField "description" let feedCtx = postCtx <> bodyField "description"
posts <- (take 10 <$>) . recentFirst =<< loadAllSnapshots "posts/*" "content"
posts <- (take 10 <$>) . recentFirst =<< loadAllSnapshots "pages/posts/*" "content"
renderRss rssfeed feedCtx posts renderRss rssfeed feedCtx posts
postCtx :: Context String postCtx :: Context String


+ 16
- 5
templates/post.html View File

@ -1,10 +1,21 @@
<div class="info"> <div class="info">
Posted on $date$
$if(author)$
by $author$
$endif$
Posted on $date$ <br />
Comment on this post <a href="#comments">here</a>
</div> </div>
<article> <article>
$body$ $body$
</article>
</article>
<hr />
<div id="comments">
<script src="https://utteranc.es/client.js"
repo="plt-hokusai/blag"
issue-term="og:title"
label="comment"
theme="github-light"
crossorigin="anonymous"
async>
</script>
</div>

Loading…
Cancel
Save