Compare commits

...

2 Commits

Author SHA1 Message Date
sxlxc 614de591ba Add notes list and integrate into templates
New partial templates/notes-list.html to render the notes list.
Add .notes-list CSS for styling and ensure contents areas use it.
Refactor site.hs: add loadNoteLinks and provide a "notes" listField
used by index and note pages.
2026-03-24 14:56:45 +08:00
sxlxc 71611b0641 Increase body line-height and add theorem padding 2026-03-23 14:54:09 +08:00
6 changed files with 41 additions and 12 deletions
+1
View File
@@ -1,6 +1,7 @@
.theorem-environment { .theorem-environment {
font-style: italic; font-style: italic;
margin-top: 1em; margin-top: 1em;
padding: 0.5em;
background-color: whitesmoke; background-color: whitesmoke;
} }
+21 -1
View File
@@ -28,7 +28,7 @@ body {
font-weight: 400; font-weight: 400;
font-style: normal; font-style: normal;
font-size: 1rem; font-size: 1rem;
line-height: 125%; line-height: 140%;
color: var(--color-text); color: var(--color-text);
background-color: var(--color-bg); background-color: var(--color-bg);
text-rendering: optimizeLegibility; text-rendering: optimizeLegibility;
@@ -264,6 +264,20 @@ ul {
list-style-type: square; list-style-type: square;
padding-left: 2em; padding-left: 2em;
} }
.notes-list {
list-style: none;
padding-left: 0;
margin-left: 0;
}
.notes-list li {
position: relative;
padding-left: 1em;
}
.notes-list li::before {
content: "-";
position: absolute;
left: 0;
}
li { li {
margin-bottom: 0.15em; margin-bottom: 0.15em;
} }
@@ -404,6 +418,12 @@ code {
margin-left: 0 margin-left: 0
} }
div#contents ul.notes-list,
div#contents-big ul.notes-list {
list-style: none;
padding-left: 0;
}
div#contents-big ul ul { div#contents-big ul ul {
list-style-type: none; list-style-type: none;
} }
+9 -3
View File
@@ -26,6 +26,11 @@ cleanIndexHtmls = return . fmap (replaceAll pattern replacement)
pattern :: String = "/index.html" pattern :: String = "/index.html"
replacement :: String -> String = const "/" replacement :: String -> String = const "/"
loadNoteLinks :: Compiler [Item String]
loadNoteLinks = do
noteIds <- sortOn toFilePath <$> getMatches "notes/*"
pure [Item noteId "" | noteId <- noteIds]
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
config :: Configuration config :: Configuration
@@ -103,7 +108,8 @@ main = hakyllWith config $ do
match "notes/*" $ do match "notes/*" $ do
route cleanRoute route cleanRoute
compile $ do compile $ do
tocCtx <- getTocCtx defaultContext notes <- loadNoteLinks
tocCtx <- getTocCtx $ listField "notes" defaultContext (return notes) <> defaultContext
chaoDocCompiler chaoDocCompiler
>>= loadAndApplyTemplate "templates/note.html" tocCtx >>= loadAndApplyTemplate "templates/note.html" tocCtx
>>= relativizeUrls >>= relativizeUrls
@@ -111,9 +117,9 @@ main = hakyllWith config $ do
create ["index.html"] $ do create ["index.html"] $ do
route idRoute route idRoute
compile $ do compile $ do
notes <- sortOn (toFilePath . itemIdentifier) <$> loadAll "notes/*" notes <- loadNoteLinks
let notesCtx = let notesCtx =
listField "posts" defaultContext (return notes) listField "notes" defaultContext (return notes)
`mappend` constField "title" "Notes" `mappend` constField "title" "Notes"
`mappend` defaultContext `mappend` defaultContext
makeItem "" makeItem ""
+2 -1
View File
@@ -11,6 +11,7 @@ $partial("templates/head.html")$
that are big enough --> that are big enough -->
<div id="contents-big"> <div id="contents-big">
<p class="mini-header">Notes <a id="up-arrow" href="/"></a></p> <p class="mini-header">Notes <a id="up-arrow" href="/"></a></p>
$partial("templates/notes-list.html")$
<p class="mini-header">Contents <a id="up-arrow" href="#"></a></p> <p class="mini-header">Contents <a id="up-arrow" href="#"></a></p>
$toc$ $toc$
</div> </div>
@@ -38,4 +39,4 @@ $partial("templates/head.html")$
</div> </div>
</body> </body>
</html> </html>
+7
View File
@@ -0,0 +1,7 @@
<ul class="notes-list">
$for(notes)$
<li>
<a href="$url$">$title$</a>
</li>
$endfor$
</ul>
+1 -7
View File
@@ -1,8 +1,2 @@
<h1 class="pagetitle">$title$</h1> <h1 class="pagetitle">$title$</h1>
<ul> $partial("templates/notes-list.html")$
$for(posts)$
<li>
<a href="$url$">$title$</a>
</li>
$endfor$
</ul>