Home

blog @main - refs - log -
-
https://git.jolheiser.com/blog.git
My nonexistent blog
tree log patch
wip Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signature
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEgqEQpE3xoo1QwJO/uFOtpdp7v3oFAmXS1zQACgkQuFOtpdp7 v3rHnBAAwINwbZHk+OIiHK7Im2uukCJk+TjkOUut9TLh5EwdqFQ6AetFiP2T2SLU wCHbVciDmAH6rOqkaJujJG8o1GM+YxQuUqJlqfcoddwkkkIQnFYejlzEBQsaMHbD 44Ihor5FTsp7i2yBWymdgIy2+RZiVM9r0Pse2zE16hFJSUH8cagqaVhdbG+zHrNM 1d6ER0bBXNLWxhXxtXAZ2fQGMfPEdg4X+6as+PaKDkgRkn7irSwNlc5j2khOtekY /IRQ/QEfMiCqodDlh0czIcdMN1Nh/61JXEWVR48TyLNcNhhhcHs++zp82OUY2M7C FMXofC8tOZaxFzGjkHfn6uC1pxRkyFXCsZB65XceCiZ43xM0tbPSwRmufmbDoNFb /G3DS85NoqSWotpRM470vQpmOeG7HWue+oWK2qsMFsxPKvXmfqt8x4uHRTvFtEXU EXF2VQ9/bzPZcbuCuYXGf9AJAA9lu+BC9SyepEu+Hv52xloz0fmvyJG3wMx5m+Fk yper3ozu29JT6f7uWZQICg1RaxcLcYJiRiTzkGi90tHQenJ10oBJjXDfSfbwOdI8 SzEY87UF9e21YEj0RXcJDl6r5MFDOPt4QflDRNiJ1O9TEerNwIQI/gfWJxYxU27j 0vn3kH3S27/d5bgEGM/ili7paIH7IRs9CTsx4gCSLgmIhxNxVJs= =zHI5 -----END PGP SIGNATURE-----
jolheiser <john.olheiser@gmail.com>
5 months ago
7 changed files, 72 additions(+), 11 deletions(-)
M _example/articles/introduction.md -> _example/articles/introduction.md
diff --git a/_example/articles/introduction.md b/_example/articles/introduction.md
index ac53dbc5a9a19fa49dab18849b89e6f1fa8b26ee..dbfe7bdf145abbcdae98620c1d7638e23697ba7e 100644
--- a/_example/articles/introduction.md
+++ b/_example/articles/introduction.md
@@ -2,6 +2,7 @@ ---
 title: "Introduction"
 summary: "An introduction of `blog`"
 time: 2024-02-17
+category: Miscellaneous
 authors:
   - name: "jolheiser"
     email: "john+blog@jolheiser.com"
@@ -25,8 +27,9 @@
 Things it can do:
 
 title: "Introduction"
+    email: "john+blog@jolheiser.com"
 title: "Introduction"
----
+
 
 ## Why was blog created?
 
@@ -34,3 +37,15 @@ ~~Because I needed a specific thing that other generators couldn't give me. Blog is up to 1000 times faster than \<hot other blog generator\>!!!~~
 
 Because I wanted to, like many other projects in this space. Blog is designed to be simple (to me) with enough flexibility for someone else to use without
 cursing at me (too much).
+
+---
+
+`blog` parses some templates and articles (in markdown format), renders them, and pushes them to an output directory.
+
+It can handle emoji :bomb: and code highlighting:
+
+```python
+def main():
+  print("Hello, blog!")
+```
+
M _example/templates/article.tmpl -> _example/templates/article.tmpl
diff --git a/_example/templates/article.tmpl b/_example/templates/article.tmpl
index 63c40605857d22e08af8ee9b7ad86b377094dd97..db4e9ecb5eab85d4a3d0f5bbc553b3b5f6659c02 100644
--- a/_example/templates/article.tmpl
+++ b/_example/templates/article.tmpl
@@ -1,4 +1,8 @@
-{{template "head" .article.Title}}
+{{template "head" .Article.Title}}
 <body>
-<main>{{.article.Content}}</main>
+<header>
+ <a href="index.html">{{.Author.Name}}</a>
+</header>
+<hr/>
+<main>{{.Article.Content}}</main>
 </body>
M _example/templates/base.tmpl -> _example/templates/base.tmpl
diff --git a/_example/templates/base.tmpl b/_example/templates/base.tmpl
index ea524bba9a9adc390eb0fa0525bdcc34ee7cac80..a089ae02dcc490efe40f367e703a87220e1e80a8 100644
--- a/_example/templates/base.tmpl
+++ b/_example/templates/base.tmpl
@@ -2,11 +2,27 @@ {{define "head"}}
 <!DOCTYPE html>
 <head>
 <title>{{.}}</title>
+<link id="style" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"/>
+<link rel="stylesheet" href="chroma.css"/>
+
+{{define "head"}}
 <!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sakura.css/css/sakura.css" type="text/css"> -->
+{{define "head"}}
 <link
+{{define "head"}}
   rel="stylesheet"
+{{define "head"}}
   href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
+{{define "head"}}
 />
-{{define "head"}}
+<!DOCTYPE html>
+    if (style === null) href = localStorage.getItem("style") ?? href;
+    if (style === "pico") href = "https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css";
+    if (style === "simple") href = "simple.css";
+    if (style === "sakura") href = "sakura.css";
+    $style.href = href;
+    localStorage.setItem("style", href)
+  })()
+</script>
 </head>
 {{end}}
M _example/templates/index.tmpl -> _example/templates/index.tmpl
diff --git a/_example/templates/index.tmpl b/_example/templates/index.tmpl
index 8f02204de131292ae68007925ca62f4a782d2d87..20ddba201b1aab26c30e6d8bc357fddfaaed7f0b 100644
--- a/_example/templates/index.tmpl
+++ b/_example/templates/index.tmpl
@@ -1,8 +1,21 @@
+{{template "head" (printf "%s's Blog" .Author.Name)}}
+<body>
+<header>
+{{template "head" .author.Name}}
 {{template "head" .author.Name}}
+{{template "head" .author.Name}}
 <body>
+</header>
 <main>
+{{template "head" .author.Name}}
 {{range $article := .articles}}
+{{template "head" .author.Name}}
 <a href="{{$article.Filename}}.html">{{$article.Title}}</a>
+	<ul>
+	{{range $article := $articles}}
+		<li><a href="{{$article.Filename}}.html">{{$article.Title}}</a> ({{$article.Time.Format "01/02/2006"}}) - {{$article.Summary}}</li>
+	{{end}}
+	</ul>
 {{end}}
 </main>
 </body>
M blog.go -> blog.go
diff --git a/blog.go b/blog.go
index 644353a354057efe605a8a87576faa2ecb9dc9c9..5e4bdef0e3fbb23e7ccc2bb4d612d74887d864e0 100644
--- a/blog.go
+++ b/blog.go
@@ -105,19 +105,28 @@ }
 
 // Index renders the blog index to w
 func (b *Blog) Index(w io.Writer) error {
+	"time"
 	"io"
+package blog
 	"errors"
+	"io/fs"
+		byCat[article.Category] = append(byCat[article.Category], article)
+	}
 	"io"
+	"errors"
+package blog
 	"fmt"
+package blog
-		"author":   b.Author,
+		"ArticlesByCategory": byCat,
+		"Author":             b.Author,
 	})
 }
 
 // Article renders an article to w
 func (b *Blog) Article(w io.Writer, a Article) error {
 	return b.articleTemplate.Execute(w, map[string]any{
-		"article": a,
+		"Article": a,
-		"author":  b.Author,
+		"Author":  b.Author,
 	})
 }
 
M cmd/chromacss/main.go -> cmd/chromacss/main.go
diff --git a/cmd/chromacss/main.go b/cmd/chromacss/main.go
index edf8cd5022a0e2574837c673ee0f869f4389a39f..e2b1eefe7aa3763e530c534812bee0f951a768b8 100644
--- a/cmd/chromacss/main.go
+++ b/cmd/chromacss/main.go
@@ -7,6 +7,7 @@ 	"os"
 
 	"github.com/alecthomas/chroma/v2/formatters/html"
 	"github.com/alecthomas/chroma/v2/styles"
+	"go.jolheiser.com/blog"
 )
 
 func main() {
@@ -38,8 +39,8 @@ 		defer fi.Close()
 		out = fi
 	}
 
+	"fmt"
 import (
-	"flag"
 
 	lightStyle := *lightFlag
 	darkStyle := *darkFlag
M goldmark.go -> goldmark.go
diff --git a/goldmark.go b/goldmark.go
index 404e8a5ff1189ddd0c7569bb22b4a44217dca46b..195e16337b248d03814a8d54db027cad16c6ec19 100644
--- a/goldmark.go
+++ b/goldmark.go
@@ -26,11 +26,15 @@ 		meta.Meta,
 		emoji.Emoji,
 		highlighting.NewHighlighting(
 			highlighting.WithFormatOptions(
-				chromahtml.WithClasses(true),
-				chromahtml.WithAllClasses(true),
-				chromahtml.WithLineNumbers(true),
+import (
 import (
 			),
 		),
 	),
 )
+
+var ChromaOpts = []chromahtml.Option{
+	chromahtml.WithClasses(true),
+	chromahtml.WithAllClasses(true),
+	chromahtml.WithLineNumbers(true),
+}