Skip to content

Commit

Permalink
Make it clear that Path is relative to content root
Browse files Browse the repository at this point in the history
Fixes #2290
  • Loading branch information
bep committed Oct 28, 2016
1 parent 4ad3944 commit 342b6fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions hugolib/page_test.go
Expand Up @@ -643,8 +643,8 @@ func TestCreateNewPage(t *testing.T) {
assertFunc := func(t *testing.T, ext string, pages Pages) {
p := pages[0]

// issue #2290: No /content in Path
// require.Equal(t, "asdf", p.Path())
// issue #2290: Path is relative to the content dir and will continue to be so.
require.Equal(t, filepath.FromSlash(fmt.Sprintf("p0.%s", ext)), p.Path())
assert.False(t, p.IsHome)
checkPageTitle(t, p, "Simple")
checkPageContent(t, p, normalizeExpected(ext, "<p>Simple Page</p>\n"))
Expand All @@ -654,7 +654,11 @@ func TestCreateNewPage(t *testing.T) {
checkTruncation(t, p, false, "simple short page")
}

testAllMarkdownEnginesForPages(t, assertFunc, nil, simplePage)
settings := map[string]interface{}{
"contentDir": "mycontent",
}

testAllMarkdownEnginesForPages(t, assertFunc, settings, simplePage)
}

func TestSplitSummaryAndContent(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions source/file.go
Expand Up @@ -25,7 +25,7 @@ import (
// File represents a source content file.
// All paths are relative from the source directory base
type File struct {
relpath string // Original relative path, e.g. content/foo.txt
relpath string // Original relative path, e.g. section/foo.txt
logicalName string // foo.txt
baseName string // `post` for `post.md`, also `post.en` for `post.en.md`
Contents io.Reader
Expand Down Expand Up @@ -101,8 +101,8 @@ func (f *File) Ext() string {
return f.Extension()
}

// Path gets the relative path including file name and extension from
// the base of the source directory.
// Path gets the relative path including file name and extension.
// The directory is relative to the content root.
func (f *File) Path() string {
return f.relpath
}
Expand Down

0 comments on commit 342b6fe

Please sign in to comment.