Fill out documentation sections with possible topics

This commit is contained in:
David Vollbracht 2023-11-12 15:39:31 -06:00
parent 2d92e721fb
commit 3a7772bbdd
10 changed files with 98 additions and 23 deletions

View File

@ -33,7 +33,9 @@ main {
} }
nav a { nav a {
display: block; display: block;
margin-top: 8px;
margin-bottom: 8px;
} }
a { a {

View File

@ -0,0 +1,6 @@
---
title: Building SQL Expressions (Upcoming)
navOrder: 2
---
Coming Soon

View File

@ -0,0 +1,6 @@
---
title: Fighting N+1 Queries with Plans (Upcoming)
navOrder: 3
---
Coming Soon

View File

@ -0,0 +1,6 @@
---
title: The MonadOrville Typeclass (Upcoming)
navOrder: 1
---
Coming Soon

View File

@ -0,0 +1,6 @@
---
title: How To Add Orville to Your Application Monad (Upcoming)
navOrder: 1
---
Coming Soon

View File

@ -0,0 +1,6 @@
---
title: How To Execute Raw SQL (Upcoming)
navOrder: 4
---
Coming Soon

View File

@ -0,0 +1,6 @@
---
title: How To Marshall a Haskell Record (Upcoming)
navOrder: 2
---
Coming Soon

View File

@ -0,0 +1,6 @@
---
title: How To Set Up An Auto-incrementing Id Column (Upcoming)
navOrder: 3
---
Coming Soon

View File

@ -45,10 +45,29 @@ renderPandocInStyle =
{ writerHighlightStyle = Just pandocCodeStyle { writerHighlightStyle = Just pandocCodeStyle
}) })
data Section =
Section
{ sectionName :: String
, sectionPattern :: Pattern
}
sections :: [Section]
sections =
[ Section "tutorials" "tutorials/**"
, Section "how-tos" "how-tos/**"
, Section "explanations" "explanations/**"
]
sectionFiles :: Pattern
sectionFiles =
foldr (.||.) (complement mempty) (map sectionPattern sections)
main :: IO () main :: IO ()
main = do main = do
hakyllWith config $ do hakyllWith config $ do
snippetCache <- preprocess newSnippetCache snippetCache <- preprocess newSnippetCache
let
navContext = mkNavContext snippetCache
match "images/*" $ do match "images/*" $ do
route idRoute route idRoute
@ -65,34 +84,27 @@ main = do
match "contact.md" $ do match "contact.md" $ do
route $ setExtension "html" route $ setExtension "html"
compile $ pandocCompiler compile $ pandocCompiler
>>= applyDefaultLayout snippetCache defaultContext >>= applyDefaultLayout navContext defaultContext
>>= relativizeUrls >>= relativizeUrls
let match sectionFiles $ do
tutorialsRoute = route (setExtension "html")
composeRoutes
(gsubRoute "tutorials/" (const ""))
(setExtension "html")
match "tutorials/**" $ do
route tutorialsRoute
compile $ compile $
getResourceBody getResourceBody
>>= applyAsTemplate (pageCtx snippetCache) >>= applyAsTemplate (pageCtx snippetCache)
>>= renderPandocInStyle >>= renderPandocInStyle
>>= loadAndApplyTemplate "templates/post.html" (pageCtx snippetCache) >>= loadAndApplyTemplate "templates/post.html" (pageCtx snippetCache)
>>= saveSnapshot navLinksSnapshot >>= saveSnapshot navLinksSnapshot
>>= applyDefaultLayout snippetCache (pageCtx snippetCache) >>= applyDefaultLayout navContext (pageCtx snippetCache)
>>= relativizeUrls >>= relativizeUrls
match "index.md" $ do match "index.md" $ do
route $ setExtension "html" route $ setExtension "html"
compile $ do compile $ do
navContext <- loadNavContex snippetCache
getResourceBody getResourceBody
>>= applyAsTemplate (mconcat [navContext, pageCtx snippetCache]) >>= applyAsTemplate (mconcat [navContext, pageCtx snippetCache])
>>= renderPandocInStyle >>= renderPandocInStyle
>>= applyDefaultLayout snippetCache defaultContext >>= applyDefaultLayout navContext defaultContext
>>= relativizeUrls >>= relativizeUrls
match "templates/*" $ compile templateBodyCompiler match "templates/*" $ compile templateBodyCompiler
@ -110,15 +122,14 @@ main = do
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
applyDefaultLayout :: applyDefaultLayout ::
SnippetCache -> Context a ->
Context a -> Context a ->
Item a -> Item a ->
Compiler (Item String) Compiler (Item String)
applyDefaultLayout snippetCache itemContext item = do applyDefaultLayout navContext itemContext item = do
navContext <- loadNavContex snippetCache
loadAndApplyTemplate loadAndApplyTemplate
"templates/default.html" "templates/default.html"
(mappend navContext itemContext) (navContext <> itemContext)
item item
{- | {- |
@ -130,11 +141,18 @@ navLinksSnapshot :: String
navLinksSnapshot = navLinksSnapshot =
"navLinks" "navLinks"
loadNavContex :: SnippetCache -> Compiler (Context a) mkNavContext :: SnippetCache -> Context a
loadNavContex snippetCache = do mkNavContext snippetCache = do
tutorials <- inNavOrder =<< loadAllSnapshots "tutorials/*" navLinksSnapshot foldMap (sectionContext snippetCache) sections
pure $
listField "tutorials" (pageCtx snippetCache) (return tutorials) sectionContext :: SnippetCache -> Section -> Context a
sectionContext snippetCache section =
listField (sectionName section) (pageCtx snippetCache) $
inNavOrder =<<
loadAllSnapshots
(sectionPattern section)
navLinksSnapshot
inNavOrder :: (MonadMetadata m, MonadFail m) => [Item a] -> m [Item a] inNavOrder :: (MonadMetadata m, MonadFail m) => [Item a] -> m [Item a]
inNavOrder = inNavOrder =

View File

@ -13,7 +13,7 @@
<header> <header>
<h1 class="logo"> <h1 class="logo">
<a href="/"> <a href="/">
<img alt="Orville Logo" src="images/orville-waving-pennant.svg"/> <img alt="Orville Logo" src="/images/orville-waving-pennant.svg"/>
</a> </a>
</h1> </h1>
</header> </header>
@ -26,6 +26,19 @@
<a href="$url$">$title$</a> <a href="$url$">$title$</a>
$endfor$ $endfor$
<h3>How-To Guides</h3>
$for(how-tos)$
<a href="$url$">$title$</a>
$endfor$
<h3>Futher Explanation</h3>
$for(explanations)$
<a href="$url$">$title$</a>
$endfor$
<h3>API Reference</h3>
<a href="https://hackage.haskell.org/package/orville-postgresql">See Hackage</a>
<h3>Other Links</h3> <h3>Other Links</h3>
<a href="/contact.html">Contact</a> <a href="/contact.html">Contact</a>
</nav> </nav>