mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Homepage "/" respects PublishDir
It wasn't taking the value of PublishDir into consideration for the special case of the homepage "/". Fixes #75
This commit is contained in:
parent
610c06e658
commit
6274aa0a64
3 changed files with 28 additions and 2 deletions
|
@ -49,8 +49,6 @@ func TestPageCount(t *testing.T) {
|
|||
s := &Site{Target: target}
|
||||
s.prepTemplates()
|
||||
must(s.addTemplate("indexes/blue.html", INDEX_TEMPLATE))
|
||||
//s.Files = append(s.Files, "blue/doc1.md")
|
||||
//s.Files = append(s.Files, "blue/doc2.md")
|
||||
s.Pages = append(s.Pages, mustReturn(ReadFrom(strings.NewReader(SLUG_DOC_1), filepath.FromSlash("content/blue/doc1.md"))))
|
||||
s.Pages = append(s.Pages, mustReturn(ReadFrom(strings.NewReader(SLUG_DOC_2), filepath.FromSlash("content/blue/doc2.md"))))
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue