{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
module Noli.Types
( Settings (..),
Post (..),
Project (..),
Page (..),
PostTemplate,
FrontMatter (..),
)
where
import Data.Aeson
import Data.Text
import GHC.Generics
import Lucid.Base
data Project
= Project
{ posts :: [Post],
pages :: [Page]
}
data Settings
= Settings
{
name :: Text,
author :: Text,
posts_location :: FilePath,
dist_location :: FilePath,
static_location :: FilePath
}
newtype FrontMatter
= FrontMatter
{ frontmatter_title :: Text
}
deriving (Show, Generic, ToJSON)
instance FromJSON FrontMatter where
parseJSON = withObject "FrontMatter" $ \obj -> do
frontmatter_title <- obj .: "title"
return (FrontMatter frontmatter_title)
data Post
= Post
{ title :: Text,
location :: FilePath,
filename :: Text,
raw :: Text,
raw_html :: Text,
compiled_html :: Html ()
}
deriving (Show)
data Page = Page {pagename :: Text, template :: Html ()}
type PostTitle = Text
type PostBody = Text
type PostTemplate = PostTitle -> PostBody -> Html ()