From 342b6fe8a584a84b83159da430773fcdb7b174e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 28 Oct 2016 10:35:19 +0200 Subject: [PATCH] Make it clear that Path is relative to content root Fixes #2290 --- hugolib/page_test.go | 10 +++++++--- source/file.go | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/hugolib/page_test.go b/hugolib/page_test.go index 85478dcf0..386ea8309 100644 --- a/hugolib/page_test.go +++ b/hugolib/page_test.go @@ -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, "

Simple Page

\n")) @@ -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) { diff --git a/source/file.go b/source/file.go index 1fd0e2a97..7e3e7d7c4 100644 --- a/source/file.go +++ b/source/file.go @@ -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 @@ -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 }