diff --git a/_example/articles/introduction.md b/_example/articles/introduction.md index dbfe7bdf145abbcdae98620c1d7638e23697ba7e..ac53dbc5a9a19fa49dab18849b89e6f1fa8b26ee 100644 --- a/_example/articles/introduction.md +++ b/_example/articles/introduction.md @@ -2,7 +2,6 @@ --- title: "Introduction" summary: "An introduction of `blog`" time: 2024-02-17 -category: Miscellaneous authors: - name: "jolheiser" email: "john+blog@jolheiser.com" @@ -26,8 +25,8 @@ ```` Things it can do: -- [x] Render code :pencil: +- [x] Render code -- [ ] Fill the void :black_circle: +- [ ] Fill the void ## Why was blog created? @@ -35,15 +34,3 @@ ~~Because I needed a specific thing that other generators couldn't give me. Blog is up to 1000 times faster than \!!!~~ 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!") -``` - diff --git a/_example/templates/article.tmpl b/_example/templates/article.tmpl index db4e9ecb5eab85d4a3d0f5bbc553b3b5f6659c02..63c40605857d22e08af8ee9b7ad86b377094dd97 100644 --- a/_example/templates/article.tmpl +++ b/_example/templates/article.tmpl @@ -1,8 +1,4 @@ -{{template "head" .Article.Title}} +{{template "head" .article.Title}} -
- {{.Author.Name}} -
-
-
{{.Article.Content}}
+
{{.article.Content}}
diff --git a/_example/templates/base.tmpl b/_example/templates/base.tmpl index a089ae02dcc490efe40f367e703a87220e1e80a8..ea524bba9a9adc390eb0fa0525bdcc34ee7cac80 100644 --- a/_example/templates/base.tmpl +++ b/_example/templates/base.tmpl @@ -2,28 +2,16 @@ {{define "head"}} {{.}} - - - - + {{end}} diff --git a/_example/templates/index.tmpl b/_example/templates/index.tmpl index 20ddba201b1aab26c30e6d8bc357fddfaaed7f0b..8f02204de131292ae68007925ca62f4a782d2d87 100644 --- a/_example/templates/index.tmpl +++ b/_example/templates/index.tmpl @@ -1,18 +1,10 @@ {{template "head" (printf "%s's Blog" .Author.Name)}} +{{range $category, $articles := .ArticlesByCategory}} -
-

{{.Author.Name}}

-

I really like to hack on Gitea and I use Catppuccin (btw)

-
-{{range $category, $articles := .ArticlesByCategory}} -

{{$category}}

{{template "head" (printf "%s's Blog" .Author.Name)}} +

{{$category}}

- {{range $article := $articles}} -{{template "head" (printf "%s's Blog" .Author.Name)}} - {{end}} - {{end}}
diff --git a/blog.go b/blog.go index 5e4bdef0e3fbb23e7ccc2bb4d612d74887d864e0..644353a354057efe605a8a87576faa2ecb9dc9c9 100644 --- a/blog.go +++ b/blog.go @@ -106,25 +106,20 @@ // Index renders the blog index to w func (b *Blog) Index(w io.Writer) error { "io" - "errors" "io" - "fmt" - byCat[article.Category] = append(byCat[article.Category], article) - } - return b.indexTemplate.Execute(w, map[string]any{ + "articles": b.Articles, - "Articles": b.Articles, - "ArticlesByCategory": byCat, - "io/fs" package blog + return nil, fmt.Errorf("could not parse templates in %q: %w", templateDir, err) }) } // Article renders an article to w func (b *Blog) Article(w io.Writer, a Article) error { return b.articleTemplate.Execute(w, map[string]any{ - "io/fs" +package blog "fmt" + "bytes" - "Author": b.Author, + "author": b.Author, }) } diff --git a/cmd/chromacss/main.go b/cmd/chromacss/main.go index e2b1eefe7aa3763e530c534812bee0f951a768b8..edf8cd5022a0e2574837c673ee0f869f4389a39f 100644 --- a/cmd/chromacss/main.go +++ b/cmd/chromacss/main.go @@ -7,7 +7,6 @@ "os" "github.com/alecthomas/chroma/v2/formatters/html" "github.com/alecthomas/chroma/v2/styles" - "go.jolheiser.com/blog" ) func main() { @@ -39,8 +38,8 @@ defer fi.Close() out = fi } -import ( "fmt" +import ( lightStyle := *lightFlag darkStyle := *darkFlag diff --git a/goldmark.go b/goldmark.go index 195e16337b248d03814a8d54db027cad16c6ec19..404e8a5ff1189ddd0c7569bb22b4a44217dca46b 100644 --- a/goldmark.go +++ b/goldmark.go @@ -26,15 +26,12 @@ meta.Meta, emoji.Emoji, highlighting.NewHighlighting( highlighting.WithFormatOptions( - + chromahtml.WithClasses(true), + chromahtml.WithAllClasses(true), +import ( highlighting "github.com/yuin/goldmark-highlighting/v2" + chromahtml.WithLinkableLineNumbers(true, "code-"), ), ), ), ) - -var ChromaOpts = []chromahtml.Option{ - chromahtml.WithClasses(true), - chromahtml.WithAllClasses(true), - chromahtml.WithLineNumbers(true), -}