Support non-md files as archetype files

It now properly uses the extension of the target file to determine archetype file.

Fixes #3597
Fixes #3618
This commit is contained in:
Bjørn Erik Pedersen 2017-06-20 12:46:03 +02:00
parent 0f40e1fadf
commit 19f2e72913
3 changed files with 23 additions and 8 deletions

View file

@ -44,6 +44,7 @@ func TestNewContent(t *testing.T) {
expected []string
}{
{"post", "post/sample-1.md", []string{`title = "Post Arch title"`, `test = "test1"`, "date = \"2015-01-12T19:20:04-07:00\""}},
{"post", "post/org-1.org", []string{`#+title: ORG-1`}},
{"emptydate", "post/sample-ed.md", []string{`title = "Empty Date Arch title"`, `test = "test1"`}},
{"stump", "stump/sample-2.md", []string{`title = "Sample 2"`}}, // no archetype file
{"", "sample-3.md", []string{`title = "Sample 3"`}}, // no archetype
@ -111,6 +112,10 @@ func initFs(fs *hugofs.Fs) error {
path: filepath.Join("archetypes", "post.md"),
content: "+++\ndate = \"2015-01-12T19:20:04-07:00\"\ntitle = \"Post Arch title\"\ntest = \"test1\"\n+++\n",
},
{
path: filepath.Join("archetypes", "post.org"),
content: "#+title: {{ .BaseFileName | upper }}",
},
{
path: filepath.Join("archetypes", "product.md"),
content: `+++