about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--cmd/build/build.go29
-rw-r--r--internal/atom/atom.go (renamed from cmd/build/atom.go)2
2 files changed, 16 insertions, 15 deletions
diff --git a/cmd/build/build.go b/cmd/build/build.go
index ddc7a6b..7d54fd1 100644
--- a/cmd/build/build.go
+++ b/cmd/build/build.go
@@ -16,7 +16,8 @@ import (
 	"strings"
 	"time"
 
-	. "website/internal/config"
+	"website/internal/atom"
+	"website/internal/config"
 
 	"github.com/BurntSushi/toml"
 	"github.com/PuerkitoBio/goquery"
@@ -123,7 +124,7 @@ func readPosts(root string, inputDir string, outputDir string) ([]Post, Tags, er
 	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 @@ func renderHTML(doc *goquery.Document) io.Reader {
 	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 @@ func renderPost(post Post, config Config) (r io.Reader, err error) {
 	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 @@ func renderTags(tags Tags, config Config) (io.Reader, error) {
 	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 @@ func renderListPage(tag string, config Config, posts []Post) (io.Reader, error)
 	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 @@ func renderHomepage(config Config, posts []Post) (io.Reader, error) {
 	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 @@ func render404(config Config) (io.Reader, error) {
 	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 @@ func renderFeed(title string, config Config, posts []Post, specific string) (io.
 	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 @@ func renderFeed(title string, config Config, posts []Post, specific string) (io.
 		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 @@ func outputToFile(output io.Reader, filename ...string) error {
 }
 
 func build() error {
-	config, err := GetConfig()
+	config, err := config.GetConfig()
 	if err != nil {
 		return err
 	}
diff --git a/cmd/build/atom.go b/internal/atom/atom.go
index bf8d318..f2ca4a9 100644
--- a/cmd/build/atom.go
+++ b/internal/atom/atom.go
@@ -1,4 +1,4 @@
-package main
+package atom
 
 import (
 	"encoding/xml"