Ensure Section is set before returning Page object.
This commit is contained in:
parent
c32f401b15
commit
bc3c229002
2 changed files with 8 additions and 0 deletions
|
@ -87,6 +87,7 @@ func NewPage(filename string) *Page {
|
||||||
Params: make(map[string]interface{}),
|
Params: make(map[string]interface{}),
|
||||||
Markup: "md"}
|
Markup: "md"}
|
||||||
page.Date, _ = time.Parse("20060102", "20080101")
|
page.Date, _ = time.Parse("20060102", "20080101")
|
||||||
|
page.guessSection()
|
||||||
return &page
|
return &page
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -219,6 +219,13 @@ func TestDegenerateInvalidFrontMatterLeadingWhitespace(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSectionEvaluation(t *testing.T) {
|
||||||
|
page, _ := ReadFrom(strings.NewReader(SIMPLE_PAGE), filepath.FromSlash("blue/file1.md"))
|
||||||
|
if page.Section != "blue" {
|
||||||
|
t.Errorf("Section should be %s, got: %s", "blue", page.Section)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestLayoutOverride(t *testing.T) {
|
func TestLayoutOverride(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
path_content_one_dir = filepath.Join("content", "gub", "file1.md")
|
path_content_one_dir = filepath.Join("content", "gub", "file1.md")
|
||||||
|
|
Loading…
Add table
Reference in a new issue