Skip to content

Commit

Permalink
create/skeletons: Honor --format flag when creating default archetype
Browse files Browse the repository at this point in the history
Closes #12666
  • Loading branch information
jmooring authored and bep committed Oct 14, 2024
1 parent 5bb22b6 commit 57151a5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
5 changes: 0 additions & 5 deletions create/skeletons/site/archetypes/default.md

This file was deleted.

21 changes: 21 additions & 0 deletions create/skeletons/skeletons.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ func CreateSite(createpath string, sourceFs afero.Fs, force bool, format string)
return err
}

err = newSiteCreateArchetype(sourceFs, createpath, format)
if err != nil {
return err
}

return copyFiles(createpath, sourceFs, siteFs)
}

Expand Down Expand Up @@ -109,3 +114,19 @@ func newSiteCreateConfig(fs afero.Fs, createpath string, format string) (err err

return helpers.WriteToDisk(filepath.Join(createpath, "hugo."+format), &buf, fs)
}

func newSiteCreateArchetype(fs afero.Fs, createpath string, format string) (err error) {
in := map[string]any{
"title": "{{ replace .File.ContentBaseName \"-\" \" \" | title }}",
"date": "{{ .Date }}",
"draft": true,
}

var buf bytes.Buffer
err = parser.InterfaceToConfig(in, metadecoders.FormatFromString(format), &buf)
if err != nil {
return err
}

return helpers.WriteToDisk(filepath.Join(createpath, "archetypes", "default.md"), &buf, fs)
}

0 comments on commit 57151a5

Please sign in to comment.