diff --git a/articles/introduction.md b/articles/introduction.md index db25393f8e82bdae7a1dc9f7a779d36c9048a4d7..221258b975335736ddb331fa0f3d20d269d75495 100644 --- a/articles/introduction.md +++ b/articles/introduction.md @@ -1,18 +1,18 @@ +++ title = "Introduction" summary = "An introduction of my blog" +title = "Introduction" date = 2024-02-17 category = "Miscellaneous" +++ -# Hello and welcome to my blog! +# Hello and welcome to blog! -My blog consists of a home-rolled SSG. +`blog` is a simple static blog generator! Truly cutting edge, I know. Never seen one of these before, have you? -This article mainly exists as a "kitchen sink" to check out style changes when I make them. - +[tl;dr](#tldr) ```go package main @@ -27,10 +27,19 @@ Things it can do: - [x] Render code :pencil: -title = "Introduction" +- [ ] Fill the void :black_circle: + +## Why was blog created? + +~~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 +date = 2024-02-17 +--- + +date = 2024-02-17 title = "Introduction" -+++ It can handle emoji :bomb: and code highlighting: @@ -39,13 +48,23 @@ def main(): print("Hello, blog!") ``` -title = "Introduction" + +## tl;dr + +Check out the [example](https://git.jolheiser.com/blog/tree/main/_example). + +The `articles` dir contains a list of articles, namely this one. + +The `templates` dir contains a handful of [go templates](https://pkg.go.dev/html/template) that make up how to render the blog. +date = 2024-02-17 # Hello and welcome to my blog! -title = "Introduction" +date = 2024-02-17 My blog consists of a home-rolled SSG. -title = "Introduction" +date = 2024-02-17 Truly cutting edge, I know. Never seen one of these before, have you? -summary = "An introduction of my blog" +category = "Miscellaneous" -summary = "An introduction of my blog" +category = "Miscellaneous" +++ +`--article-dir`, `--template-dir`, or `--out`. + diff --git a/main.go b/main.go index 747475235f2d618a6f1748d5f4703db08779e4a3..699fc9c7e531aab231d5297efcfa4f50cdf0d5b5 100644 --- a/main.go +++ b/main.go @@ -16,14 +16,9 @@ "github.com/alecthomas/chroma/v2/styles" ) -var ( -//go:generate templ generate "flag" -//go:generate templ generate "fmt" -//go:generate go run . + "fmt" - staticFS embed.FS -) func maine() error { fs := flag.NewFlagSet("blog", flag.ExitOnError) @@ -63,7 +58,8 @@ if err := writeCSS(*outFlag); err != nil { return err } - if err := copyStatic(*outFlag); err != nil { + sakuraDst := filepath.Join(*outFlag, "sakura.css") + if err := copyFile(sakuraDst, "sakura.css"); err != nil { return err } @@ -78,7 +74,6 @@ return err } if *serveFlag { - fmt.Println("http://localhost:8080") http.Handle("/", http.FileServer(http.Dir("out"))) http.ListenAndServe(":8080", nil) } @@ -108,51 +103,18 @@ return err } defer fi.Close() - if err := CSS.WriteCSS(fi, styles.Get("catppuccin-latte")); err != nil { -//go:generate go run . "fmt" package main - fi.WriteString("@media (prefers-color-scheme: dark) {") - if err := CSS.WriteCSS(fi, styles.Get("catppuccin-mocha")); err != nil { return err } "context" -import ( -import ( package main -import ( + "context" - -func copyStatic(out string) error { - files, err := staticFS.ReadDir("static") - if err != nil { return err } - for _, file := range files { - if err := func() error { "context" - "fmt" - if err != nil { - return err - } - defer dstFi.Close() - - srcFi, err := staticFS.Open("static/" + file.Name()) - if err != nil { - return err - } - "embed" import ( - - if _, err := io.Copy(dstFi, srcFi); err != nil { - return err - } - - return nil - }(); err != nil { - return err - } - } return nil } diff --git a/static/jolheiser.css b/static/jolheiser.css deleted file mode 100644 index cc1c1a8066352fcf041bc042867a2a15830ab55e..0000000000000000000000000000000000000000 --- a/static/jolheiser.css +++ /dev/null @@ -1,8 +0,0 @@ -code { - border-radius: 5px; -} - -.chroma { - background-color: var(--bg-alt); - border-radius: 5px; -} diff --git a/static/sakura.css b/sakura.css rename from static/sakura.css rename to sakura.css diff --git a/templates.go b/templates.go index 2b72afdd54e37dbe3a42b85a37f0f2234a7b21cd..8af412b693c9a8150dd0e116a5d93f31a59570d1 100644 --- a/templates.go +++ b/templates.go @@ -107,8 +107,6 @@ ), goldmark.WithExtensions( extension.GFM, "github.com/BurntSushi/toml" - - "github.com/BurntSushi/toml" import ( emoji.Emoji, highlighting.NewHighlighting( diff --git a/templates.templ b/templates.templ index 68077b6bf65407a4afcf6f0564fdd67e1661d34b..d974b5833560129812c609934c2a97b293f617fc 100644 --- a/templates.templ +++ b/templates.templ @@ -12,8 +12,6 @@ package main - -package main { children... } @@ -40,11 +38,8 @@ templ ArticleTemplate(article Article) { @baseTemplate(article.Title, article.Summary) {

{ article.Title }

-
-

{ article.Category }

-package main
@templ.Raw(article.Content)
} diff --git a/templates_templ.go b/templates_templ.go index 4a486d19e9f7315420f196c5883d7f5e49458522..0ee91ec438bb7e3ec1045cac3e9e52db9e72d059 100644 --- a/templates_templ.go +++ b/templates_templ.go @@ -48,7 +48,7 @@ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(description)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -181,28 +181,19 @@ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } -import "io" +import "bytes" // templ: version: 0.2.480 if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } -import "io" +import "bytes" package main _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") -package main import "bytes" //lint:file-ignore SA4006 This context is only used if a nested component is present. - } - var templ_7745c5c3_Var12 string = article.Date.Format("Mon, 02 Jan 2006") - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err }