Skip to content

Commit

Permalink
more better rss
Browse files Browse the repository at this point in the history
  • Loading branch information
zachary822 committed Nov 28, 2023
1 parent 5f5ca4a commit e854343
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
15 changes: 15 additions & 0 deletions app/Lib/Rss/Attributes.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{-# LANGUAGE OverloadedStrings #-}

module Lib.Rss.Attributes (
module Text.Blaze,
module Lib.Rss.Attributes,
) where

import Text.Blaze
import Text.Blaze.Internal

href :: AttributeValue -> Attribute
href = attribute "href" "href=\""

rel :: AttributeValue -> Attribute
rel = attribute "rel" "rel=\""
6 changes: 4 additions & 2 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import Lib.Blaze
import Lib.Database
import Lib.Middleware
import Lib.Rss
import Lib.Rss.Attributes qualified as RA
import Lib.Types
import Network.HTTP.Types
import Network.Socket as S
Expand Down Expand Up @@ -461,16 +462,17 @@ main = do

rssXml $ do
xmlHeader
rss $ do
rss . channel $ do
title "ThoughtBank Blog"
link "http://localhost:5173"
atomLink RA.! RA.href "http://localhost:5173/posts/feed" RA.! RA.rel "self"
description "Thoughts and concerns from my programming journey."
language "en-us"
forM_ posts $ \p -> item $ do
let l = toRss $ "http://localhost:5173/posts/" <> show (postId p)

title . toRss $ postTitle p
pubDate . toRss . formatTime defaultTimeLocale "%a, %e %b %Y %R %z" $ postUpdated p
pubDate . toRss . formatTime defaultTimeLocale "%a, %d %b %Y %R %z" $ postUpdated p
link l
guid l
description . cdata . mdToHtml $ postBody p
1 change: 1 addition & 0 deletions haskell-blog.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ executable haskell-blog
other-modules: Lib.Blaze,
Lib.Database,
Lib.Rss,
Lib.Rss.Attributes,
Lib.Middleware,
Lib.Types

Expand Down

0 comments on commit e854343

Please sign in to comment.