Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/target
diff options
context:
space:
mode:
authorNoah Campbell <noahcampbell@gmail.com>2013-09-05 20:57:25 +0400
committerNoah Campbell <noahcampbell@gmail.com>2013-09-05 20:57:25 +0400
commit6274aa0a64b0cb229a556d71c1d34d4139446aaa (patch)
tree480b4ed9357931cb3de65e4e6086e2e1f11f2e3f /target
parent610c06e6589770d950d8fd4e01efd90b132fcff5 (diff)
Homepage "/" respects PublishDir
It wasn't taking the value of PublishDir into consideration for the special case of the homepage "/". Fixes #75
Diffstat (limited to 'target')
-rw-r--r--target/file.go3
-rw-r--r--target/file_test.go25
2 files changed, 28 insertions, 0 deletions
diff --git a/target/file.go b/target/file.go
index 29c019f4e..f5ae62db3 100644
--- a/target/file.go
+++ b/target/file.go
@@ -56,6 +56,9 @@ func (fs *Filesystem) Publish(path string, r io.Reader) (err error) {
func (fs *Filesystem) Translate(src string) (dest string, err error) {
if src == "/" {
+ if fs.PublishDir != "" {
+ return path.Join(fs.PublishDir, "index.html"), nil
+ }
return "index.html", nil
}
diff --git a/target/file_test.go b/target/file_test.go
index 14e47ee6f..ee474c1c4 100644
--- a/target/file_test.go
+++ b/target/file_test.go
@@ -32,6 +32,31 @@ func TestFileTranslator(t *testing.T) {
}
}
+func TestFileTranslatorBase(t *testing.T) {
+ tests := []struct {
+ content string
+ expected string
+ }{
+ {"/", "a/base/index.html"},
+ }
+
+ for _, test := range tests {
+ f := &Filesystem{PublishDir: "a/base"}
+ fts := &Filesystem{PublishDir: "a/base/"}
+
+ for _, fs := range []*Filesystem{f, fts} {
+ dest, err := fs.Translate(test.content)
+ if err != nil {
+ t.Fatalf("Translated returned and err: %s", err)
+ }
+
+ if dest != test.expected {
+ t.Errorf("Translate expected: %s, got: %s", test.expected, dest)
+ }
+ }
+ }
+}
+
func TestTranslateUglyUrls(t *testing.T) {
tests := []struct {
content string