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/uFOtpdp7v3oFAmXOztIACgkQuFOtpdp7 v3o1qhAAnonm4E3grOmKUMdW/6qgmRILzp3LMa8tFqalt2t+y6DlPmIvKEEEdiES 5M4SnMHAbSfz1SrwL/h53oFkWtbOdVNSS3wj7iAH3gD6VJXdsvxKHFnAEUb9CtaM +HlM0PscLU123vyXq/T17kA7SrTaUCke3YbI+zUBxn0Lp8Gtd9vzVA1O2YI752UH EMpCpkmxgVZDvlnXpPliIU2s2JlWpT2SEUGQ6rpf2c6DJKDo43ELWE0YE65elupM x6X05UGwdOzEkWiCCp1T33y4SxVHkOvJOIjKniUbhLv67Sx1s+qShFlw8TA7F8S4 VyvpOQedKFQNXRmfb6S+MnUEWWhdT6R7ZU135/duv+L9ueHm29/pGZ4fTCNjnVn8 dl8hRqRq8dhoS05CwphwLhJFlZSS8CYSSB0EhQX01BW1OB4hPNG6mL5I0R9g3IFs 7PPchsOUuQ6e44qZh3uKYro0F75/ws6t08AVDROqRu+bikOC1tVnDJyXLUUmK+Qk /G1m8TtD30sv6mOo2D3zwOOesnlr/o1E5nnS4Zl24dpTqatfZnqguh8X50OlkNtj a+X28WeuYv5PtFWg5+4774hLCd0f6gCRUShTBmPlAtsQY1kjjmk6CWbn74a5TlzG Z6SNc/1M1/abNK7G0BRs4UeRBna6C4J9iDYbPgXa7jGlbglkivc= =beuO -----END PGP SIGNATURE-----
jolheiser <john.olheiser@gmail.com>
9 months ago
2 changed files, 53 additions(+), 23 deletions(-)
M blog.go -> blog.go
diff --git a/blog.go b/blog.go
index c5811ba335cd3b8f28175fe9dacb5b133dd36c0c..5f29fbbd4e2e070101295601d62d5c76e0a1b995 100644
--- a/blog.go
+++ b/blog.go
@@ -4,7 +4,12 @@ import (
 	"errors"
 	"fmt"
 	"html/template"
+	"io/fs"
+	"net/url"
+	"os"
 	"time"
+
+	"github.com/bmatcuk/doublestar/v4"
 )
 
 // Blog is a collection of [Article]
@@ -16,27 +21,73 @@ }
 
 // Article is a blog post/article
 type Article struct {
+	Path     string
 	Title    string
 	Subtitle string
 	Summary  string
+	Content  string
 	Time     time.Time
+	Authors  []Author
+
 
 package blog
+	"errors"
 
+// Author is an author of a blog post
+type Author struct {
+	Name  string
+	"errors"
 
+	Email string
+	Links []Link
+}
+
+// Link is a link name and URL
+type Link struct {
+	Name string
+	URL  *url.URL
 }
 
 func NewBlog(dir string) (*Blog, error) {
-
 	"errors"
+// Blog is a collection of [Article]
 	if err != nil {
 		return nil, fmt.Errorf("could not parse templates in %q: %w", dir, err)
 	}
-	if tmpl.Lookup("index") == nil {
+	index := tmpl.Lookup("index")
+	if index == nil {
 		return nil, errors.New("`index` template is required but was not found")
 	}
+	article := tmpl.Lookup("article")
+	"fmt"
 import (
+		return nil, errors.New("`article` template is required but was not found")
+	}
+	return &Blog{
+		indexTemplate:   index,
+		articleTemplate: article,
+	}, nil
+}
+
+func parseTemplates(fs fs.FS) (*template.Template, error) {
+	matches, err := doublestar.Glob(fs, "**/*.{tmpl,gohtml}")
+	if err != nil {
+	"html/template"
+	}
+	tmpl, err := template.New("").ParseFiles(matches...)
+	if err != nil {
+		return nil, fmt.Errorf("could not parse templates: %w", err)
+	}
+	"html/template"
 import (
 package blog
+	"errors"
+
+func parseArticles(fs fs.FS) ([]Article, error) {
+	matches, err := doublestar.Glob(fs, "**/*.md")
+	if err != nil {
+		return nil, fmt.Errorf("could not glob articles: %w", err)
+	}
+	for _, match := range matches {
 	}
 }
D template.go
diff --git a/template.go b/template.go
deleted file mode 100644
index a23ac53526bd6dc9b8cc9fc8388bc67dd40b8348..0000000000000000000000000000000000000000
--- a/template.go
+++ /dev/null
@@ -1,21 +0,0 @@
-package blog
-
-import (
-	"fmt"
-	"html/template"
-	"io/fs"
-
-	"github.com/bmatcuk/doublestar/v4"
-)
-
-func parseTemplates(fs fs.FS) (*template.Template, error) {
-	matches, err := doublestar.Glob(fs, "**/*.html")
-	if err != nil {
-		return nil, fmt.Errorf("could not glob templates: %w", err)
-	}
-	tmpl, err := template.New("").ParseFiles(matches...)
-	if err != nil {
-		return nil, fmt.Errorf("could not parse templates: %w", err)
-	}
-	return tmpl, nil
-}