all repos — website @ 4dfd72e68c385a6f02370e38831f33e644276055

My website

use internal imports correctly
Alan Pearce alan@alanpearce.eu
Wed, 17 Apr 2024 20:31:14 +0200
commit

4dfd72e68c385a6f02370e38831f33e644276055

parent

347d0cd1a73921a8cbc43798a7fbe2095791bbe9

2 files changed, 16 insertions(+), 15 deletions(-)

jump to
M cmd/build/atom.gointernal/atom/atom.go
@@ -1,4 +1,4 @@-package main
+package atom
 
 import (
 	"encoding/xml"
M cmd/build/build.gocmd/build/build.go
@@ -16,7 +16,8 @@ "slices" 	"strings"
 	"time"
 
-	. "website/internal/config"
+	"website/internal/atom"
+	"website/internal/config"
 
 	"github.com/BurntSushi/toml"
 	"github.com/PuerkitoBio/goquery"
@@ -123,7 +124,7 @@ }) 	return posts, tags, nil
 }
 
-func layout(filename string, config Config, pageTitle string) (*goquery.Document, error) {
+func layout(filename string, config config.Config, pageTitle string) (*goquery.Document, error) {
 	html, err := os.Open(filename)
 	if err != nil {
 		return nil, err
@@ -160,7 +161,7 @@ }() 	return r
 }
 
-func renderPost(post Post, config Config) (r io.Reader, err error) {
+func renderPost(post Post, config config.Config) (r io.Reader, err error) {
 	doc, err := layout("templates/post.html", config, post.PostMatter.Title)
 	if err != nil {
 		return nil, err
@@ -184,7 +185,7 @@ 	return renderHTML(doc), nil
 }
 
-func renderTags(tags Tags, config Config) (io.Reader, error) {
+func renderTags(tags Tags, config config.Config) (io.Reader, error) {
 	doc, err := layout("templates/tags.html", config, config.Title)
 	if err != nil {
 		return nil, err
@@ -200,7 +201,7 @@ } 	return renderHTML(doc), nil
 }
 
-func renderListPage(tag string, config Config, posts []Post) (io.Reader, error) {
+func renderListPage(tag string, config config.Config, posts []Post) (io.Reader, error) {
 	var title string
 	if len(tag) > 0 {
 		title = tag
@@ -234,7 +235,7 @@ 	return renderHTML(doc), nil
 }
 
-func renderHomepage(config Config, posts []Post) (io.Reader, error) {
+func renderHomepage(config config.Config, posts []Post) (io.Reader, error) {
 	_, index, err := getPost("content/_index.md")
 	if err != nil {
 		return nil, err
@@ -285,7 +286,7 @@ 	return renderHTML(doc), nil
 }
 
-func render404(config Config) (io.Reader, error) {
+func render404(config config.Config) (io.Reader, error) {
 	doc, err := layout("templates/404.html", config, "404 Not Found")
 	if err != nil {
 		return nil, err
@@ -293,7 +294,7 @@ } 	return renderHTML(doc), nil
 }
 
-func renderFeed(title string, config Config, posts []Post, specific string) (io.Reader, error) {
+func renderFeed(title string, config config.Config, posts []Post, specific string) (io.Reader, error) {
 	reader, err := os.Open("templates/feed.xml")
 	if err != nil {
 		return nil, err
@@ -303,7 +304,7 @@ doc, err := xmlquery.Parse(reader) 	feed := doc.SelectElement("feed")
 	feed.SelectElement("title").FirstChild.Data = title
 	feed.SelectElement("link").SetAttr("href", config.BaseURL.String())
-	feed.SelectElement("id").FirstChild.Data = MakeTagURI(config, specific)
+	feed.SelectElement("id").FirstChild.Data = atom.MakeTagURI(config, specific)
 	datetime, err := posts[0].Date.UTC().MarshalText()
 	feed.SelectElement("updated").FirstChild.Data = string(datetime)
 	tpl := feed.SelectElement("entry")
@@ -314,14 +315,14 @@ fullURL, err := url.JoinPath(config.BaseURL.String(), post.URL) 		if err != nil {
 			return nil, err
 		}
-		text, err := xml.MarshalIndent(&FeedEntry{
+		text, err := xml.MarshalIndent(&atom.FeedEntry{
 			Title:   post.Title,
-			Link:    MakeLink(fullURL),
-			Id:      MakeTagURI(config, post.Basename),
+			Link:    atom.MakeLink(fullURL),
+			Id:      atom.MakeTagURI(config, post.Basename),
 			Updated: post.Date.UTC(),
 			Summary: post.Description,
 			Author:  config.Title,
-			Content: FeedContent{
+			Content: atom.FeedContent{
 				Content: post.Content,
 				Type:    "html",
 			},
@@ -391,7 +392,7 @@ return nil }
 
 func build() error {
-	config, err := GetConfig()
+	config, err := config.GetConfig()
 	if err != nil {
 		return err
 	}