all repos — website @ b4095d108a2646bcf9e7fff64788b10d9bce8da3

My website

build outside of working directory

Alan Pearce
commit

b4095d108a2646bcf9e7fff64788b10d9bce8da3

parent

e8221541404a8d2ca0758d48ba5fe9c85f9067ac

1 file changed, 8 insertions(+), 7 deletions(-)

changed files
M internal/builder/template.gointernal/builder/template.go
@@ -27,8 +27,8 @@ "xhtml": "http://www.w3.org/1999/xhtml",
} ) -func loadCSS() { - bytes, err := os.ReadFile("templates/style.css") +func loadCSS(source string) { + bytes, err := os.ReadFile(filepath.Join(source, "templates/style.css")) if err != nil { panic(err) }
@@ -66,9 +66,9 @@ func (q *QueryDocument) Find(selector string) *QuerySelection {
return &QuerySelection{q.Document.Find(selector)} } -func renderRobotsTXT(config *config.Config) (io.Reader, error) { +func renderRobotsTXT(source string, config *config.Config) (io.Reader, error) { r, w := io.Pipe() - tpl, err := template.ParseFiles("templates/robots.tmpl") + tpl, err := template.ParseFiles(filepath.Join(source, "templates/robots.tmpl")) if err != nil { return nil, err }
@@ -86,12 +86,13 @@ return r, nil
} func renderFeed( + source string, title string, config *config.Config, posts []content.Post, specific string, ) (io.Reader, error) { - reader, err := loadTemplate("templates/feed.xml") + reader, err := loadTemplate(filepath.Join(source, "templates/feed.xml")) if err != nil { return nil, err }
@@ -153,8 +154,8 @@
return strings.NewReader(doc.OutputXML(true)), nil } -func renderFeedStyles() (*strings.Reader, error) { - tpl, err := template.ParseFiles("templates/feed-styles.xsl") +func renderFeedStyles(source string) (*strings.Reader, error) { + tpl, err := template.ParseFiles(filepath.Join(source, "templates/feed-styles.xsl")) if err != nil { return nil, err }