aboutsummaryrefslogtreecommitdiffhomepage
path: root/create
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
parent5bb22b6b4e459fcba2944a6d1ce66c91413f8f75 (diff)
downloadhugo-57151a5e911cd4a951925b231d67e62b19a54a47.tar.gz
hugo-57151a5e911cd4a951925b231d67e62b19a54a47.zip
create/skeletons: Honor --format flag when creating default archetype
Closes #12666
Diffstat (limited to 'create')
-rw-r--r--create/skeletons/site/archetypes/default.md5
-rw-r--r--create/skeletons/skeletons.go21
2 files changed, 21 insertions, 5 deletions
diff --git a/create/skeletons/site/archetypes/default.md b/create/skeletons/site/archetypes/default.md
deleted file mode 100644
index c6f3fcef6..000000000
--- a/create/skeletons/site/archetypes/default.md
+++ /dev/null
@@ -1,5 +0,0 @@
-+++
-title = '{{ replace .File.ContentBaseName "-" " " | title }}'
-date = {{ .Date }}
-draft = true
-+++
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)
+}