about summary refs log tree commit diff stats
path: root/internal/builder
diff options
context:
space:
mode:
Diffstat (limited to 'internal/builder')
-rw-r--r--internal/builder/builder.go42
1 files changed, 17 insertions, 25 deletions
diff --git a/internal/builder/builder.go b/internal/builder/builder.go
index 177fa2f..0bf6cb2 100644
--- a/internal/builder/builder.go
+++ b/internal/builder/builder.go
@@ -22,7 +22,7 @@ import (
 
 type IOConfig struct {
 	Source      string `conf:"default:.,short:s,flag:src"`
-	Destination string `conf:"default:website,short:d,flag:dest"`
+	Destination string `conf:"default:public,short:d,flag:dest"`
 	Development bool   `conf:"default:false,flag:dev"`
 }
 
@@ -91,25 +91,17 @@ func build(outDir string, config *config.Config) (*Result, error) {
 	r := &Result{
 		Hashes: make([]string, 0),
 	}
-	privateDir := path.Join(outDir, "private")
-	if err := mkdirp(privateDir); err != nil {
-		return nil, errors.WithMessage(err, "could not create private directory")
-	}
-	publicDir := path.Join(outDir, "public")
-	if err := mkdirp(publicDir); err != nil {
-		return nil, errors.WithMessage(err, "could not create public directory")
-	}
 
-	err := copyRecursive("static", publicDir)
+	err := copyRecursive("static", outDir)
 	if err != nil {
 		return nil, errors.WithMessage(err, "could not copy static files")
 	}
 
-	if err := mkdirp(publicDir, "post"); err != nil {
+	if err := mkdirp(outDir, "post"); err != nil {
 		return nil, errors.WithMessage(err, "could not create post output directory")
 	}
 	log.Debug("reading posts")
-	posts, tags, err := content.ReadPosts("content", "post", publicDir)
+	posts, tags, err := content.ReadPosts("content", "post", outDir)
 	if err != nil {
 		return nil, err
 	}
@@ -121,7 +113,7 @@ func build(outDir string, config *config.Config) (*Result, error) {
 	}
 
 	for _, post := range posts {
-		if err := mkdirp(publicDir, "post", post.Basename); err != nil {
+		if err := mkdirp(outDir, "post", post.Basename); err != nil {
 			return nil, errors.WithMessage(err, "could not create directory for post")
 		}
 		log.Debug("rendering post", "post", post.Basename)
@@ -131,13 +123,13 @@ func build(outDir string, config *config.Config) (*Result, error) {
 		}
 	}
 
-	if err := mkdirp(publicDir, "tags"); err != nil {
+	if err := mkdirp(outDir, "tags"); err != nil {
 		return nil, errors.WithMessage(err, "could not create directory for tags")
 	}
 	log.Debug("rendering tags list")
 	if err := renderToFile(
 		templates.TagsPage(config, "tags", mapset.Sorted(tags), "/tags"),
-		publicDir,
+		outDir,
 		"tags",
 		"index.html",
 	); err != nil {
@@ -152,14 +144,14 @@ func build(outDir string, config *config.Config) (*Result, error) {
 				matchingPosts = append(matchingPosts, post)
 			}
 		}
-		if err := mkdirp(publicDir, "tags", tag); err != nil {
+		if err := mkdirp(outDir, "tags", tag); err != nil {
 			return nil, errors.WithMessage(err, "could not create directory")
 		}
 		log.Debug("rendering tags page", "tag", tag)
 		url := "/tags/" + tag
 		if err := renderToFile(
 			templates.TagPage(config, tag, matchingPosts, url),
-			publicDir,
+			outDir,
 			"tags",
 			tag,
 			"index.html",
@@ -178,13 +170,13 @@ func build(outDir string, config *config.Config) (*Result, error) {
 		if err != nil {
 			return nil, errors.WithMessage(err, "could not render tag feed page")
 		}
-		if err := outputToFile(feed, publicDir, "tags", tag, "atom.xml"); err != nil {
+		if err := outputToFile(feed, outDir, "tags", tag, "atom.xml"); err != nil {
 			return nil, err
 		}
 	}
 
 	log.Debug("rendering list page")
-	if err := renderToFile(templates.ListPage(config, posts, "/post"), publicDir, "post", "index.html"); err != nil {
+	if err := renderToFile(templates.ListPage(config, posts, "/post"), outDir, "post", "index.html"); err != nil {
 		return nil, err
 	}
 	sitemap.AddPath("/post/", lastMod)
@@ -194,7 +186,7 @@ func build(outDir string, config *config.Config) (*Result, error) {
 	if err != nil {
 		return nil, errors.WithMessage(err, "could not render feed")
 	}
-	if err := outputToFile(feed, publicDir, "atom.xml"); err != nil {
+	if err := outputToFile(feed, outDir, "atom.xml"); err != nil {
 		return nil, err
 	}
 
@@ -203,7 +195,7 @@ func build(outDir string, config *config.Config) (*Result, error) {
 	if err != nil {
 		return nil, errors.WithMessage(err, "could not render feed styles")
 	}
-	if err := outputToFile(feedStyles, publicDir, "feed-styles.xsl"); err != nil {
+	if err := outputToFile(feedStyles, outDir, "feed-styles.xsl"); err != nil {
 		return nil, err
 	}
 	_, err = feedStyles.Seek(0, 0)
@@ -225,18 +217,18 @@ func build(outDir string, config *config.Config) (*Result, error) {
 	if err != nil {
 		return nil, err
 	}
-	if err := renderToFile(templates.Homepage(config, posts, content), publicDir, "index.html"); err != nil {
+	if err := renderToFile(templates.Homepage(config, posts, content), outDir, "index.html"); err != nil {
 		return nil, err
 	}
 	// it would be nice to set LastMod here, but using the latest post
 	// date would be wrong as the homepage has its own content file
 	// without a date, which could be newer
 	sitemap.AddPath("/", time.Time{})
-	h, _ = getHTMLStyleHash(publicDir, "index.html")
+	h, _ = getHTMLStyleHash(outDir, "index.html")
 	r.Hashes = append(r.Hashes, h)
 
 	log.Debug("rendering sitemap")
-	if err := writerToFile(sitemap, publicDir, "sitemap.xml"); err != nil {
+	if err := writerToFile(sitemap, outDir, "sitemap.xml"); err != nil {
 		return nil, err
 	}
 
@@ -245,7 +237,7 @@ func build(outDir string, config *config.Config) (*Result, error) {
 	if err != nil {
 		return nil, err
 	}
-	if err := outputToFile(rob, publicDir, "robots.txt"); err != nil {
+	if err := outputToFile(rob, outDir, "robots.txt"); err != nil {
 		return nil, err
 	}