ensuring metadata gets pulled when creating new content

pull/8/head
Stephen Searles 7 years ago
parent 2595c37b72
commit e6735a3ecc
  1. 25
      content.go
  2. 5
      doc_test.go

@ -59,20 +59,15 @@ func GetContent(siteRoot string, sites *hugolib.HugoSites) ([]Content, error) {
return nil, err return nil, err
} }
pages := sites.Pages() for i, file := range files {
for _, page := range pages { fn := path.Join(siteRoot, file.Filename)
if page.Kind == hugolib.KindPage { page := sites.GetContentPage(fn)
for i, file := range files { if page != nil {
path := path.Join("content", page.Source.Path()) files[i].Metadata = &Metadata{
if file.Filename == path { Title: page.Title,
files[i].Metadata = &Metadata{ Path: file.Filename,
Title: page.Title, Date: page.Date,
Path: path, Lastmod: page.Lastmod,
Date: page.Date,
Lastmod: page.Lastmod,
}
break
}
} }
} }
} }
@ -110,5 +105,7 @@ func (ch CaddyHugo) NewContent(name, ctype string) (string, error) {
} }
} }
ch.Build()
return filename, nil return filename, nil
} }

@ -115,7 +115,7 @@ func TestPagesInPagesOut(t *testing.T) {
t.Fatalf("couldn't get content from the test environment: %v", err) t.Fatalf("couldn't get content from the test environment: %v", err)
} }
if len(c)-1 != i { if len(c)-1 != i {
t.Fatalf("expected %d page, but saw %d pages", i-1, len(c)) t.Fatalf("expected %d page, but saw %d pages", i+1, len(c))
} }
} }
@ -127,6 +127,9 @@ func TestPagesInPagesOut(t *testing.T) {
} }
for _, content := range c { for _, content := range c {
if content.Metadata == nil {
t.Errorf("didn't see metadata for %q", content.Filename)
}
found[content.Filename] = true found[content.Filename] = true
} }

Loading…
Cancel
Save