diff options
author | Alex Scerba <alex@scerba.org> | 2025-02-11 15:05:15 -0500 |
---|---|---|
committer | Alex Scerba <alex@scerba.org> | 2025-02-11 15:05:15 -0500 |
commit | f04fb5cf14385581c2c0d0efd204d2afd2139221 (patch) | |
tree | 5373990013b16bbc6215110cda3278462820b841 | |
parent | 80e44b3e15dc1f571b959c10034d55322cbd03c4 (diff) |
Remove redundant data type
-rw-r--r-- | cmd/http/load.go | 9 | ||||
-rw-r--r-- | html/blog2.tmpl.html | 4 |
2 files changed, 4 insertions, 9 deletions
diff --git a/cmd/http/load.go b/cmd/http/load.go index 6ab2eba..6e0c031 100644 --- a/cmd/http/load.go +++ b/cmd/http/load.go @@ -15,13 +15,8 @@ type Post struct { Tags []string } -// Posts stuct contains a collection of type Post -type Posts struct { - Collection []*Post -} - // Read all found files and load them into a stuct -func (app *application) aggregate(location string) (p *Posts, err error) { +func (app *application) aggregate(location string) (p []*Post, err error) { var posts []*Post files, err := os.ReadDir(location) @@ -42,7 +37,7 @@ func (app *application) aggregate(location string) (p *Posts, err error) { return posts[i].Date > posts[j].Date }) - return &Posts{Collection: posts}, nil + return posts, nil } func (app *application) parseFileName(file string) (p *Post) { diff --git a/html/blog2.tmpl.html b/html/blog2.tmpl.html index 2a57226..f6b0215 100644 --- a/html/blog2.tmpl.html +++ b/html/blog2.tmpl.html @@ -21,7 +21,7 @@ <p>A collection of thoughts, life updates, projects, and images.</p> </div> <div class="entries"> -{{ range .Posts.Collection }} +{{ range .Posts }} <p><a href="/blog/{{ .File }}"><b>{{ .Date }}</b> | {{ .Title }}</a></p> {{ end }} </div> @@ -31,7 +31,7 @@ <p>Works from my last revision of scerba.org</p> </div> <div class="entries"> -{{ range .Archive.Collection }} +{{ range .Archive }} <p><a href="/archive/{{ .File }}"><b>{{ .Date }}</b> | {{ .Title }}</a></p> {{ end }} </div> |