aboutsummaryrefslogtreecommitdiffhomepage
path: root/create/skeletons/skeletons.go
diff options
context:
space:
mode:
authorJoe Mooring <[email protected]>2024-10-12 12:11:08 -0700
committerBjørn Erik Pedersen <[email protected]>2024-10-14 09:54:29 +0200
commit57151a5e911cd4a951925b231d67e62b19a54a47 (patch)
tree50d3c1a640a2ce5d98ed92a1bbf5ae6825a6510b /create/skeletons/skeletons.go
parent5bb22b6b4e459fcba2944a6d1ce66c91413f8f75 (diff)
downloadhugo-57151a5e911cd4a951925b231d67e62b19a54a47.tar.gz
hugo-57151a5e911cd4a951925b231d67e62b19a54a47.zip
create/skeletons: Honor --format flag when creating default archetype
Closes #12666
Diffstat (limited to 'create/skeletons/skeletons.go')
-rw-r--r--create/skeletons/skeletons.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/create/skeletons/skeletons.go b/create/skeletons/skeletons.go
index aec79c149..802b15fb0 100644
--- a/create/skeletons/skeletons.go
+++ b/create/skeletons/skeletons.go
@@ -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)
}
@@ -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)
+}