Skip to content
/ hugo Public
forked from gohugoio/hugo

Commit

Permalink
create/skeletons: Honor --format flag when creating default archetype
Browse files Browse the repository at this point in the history
  • Loading branch information
jmooring committed Oct 12, 2024
1 parent 5b0b663 commit 1fb7b70
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 1fb7b70

Please sign in to comment.