summaryrefslogtreecommitdiffstats
path: root/create/content.go
diff options
context:
space:
mode:
authorsatotake <doublequotation@gmail.com>2022-09-01 00:23:31 +0900
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-09-08 15:35:11 +0200
commit7d40da876c62a166bdd273209b7cd6bead9266c1 (patch)
treef4a0aa6c7f45cbfc4181bcff8586db98a580be53 /create/content.go
parent02c89a446d1a76491bfb4b9a756d892a83584d17 (diff)
Add `--force` to `hugo new`
Closes #9243
Diffstat (limited to 'create/content.go')
-rw-r--r--create/content.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/create/content.go b/create/content.go
index 5f05e25f9..0b9f27797 100644
--- a/create/content.go
+++ b/create/content.go
@@ -52,7 +52,7 @@ draft: true
// NewContent creates a new content file in h (or a full bundle if the archetype is a directory)
// in targetPath.
-func NewContent(h *hugolib.HugoSites, kind, targetPath string) error {
+func NewContent(h *hugolib.HugoSites, kind, targetPath string, force bool) error {
if h.BaseFs.Content.Dirs == nil {
return errors.New("no existing content directory configured for this project")
}
@@ -76,6 +76,7 @@ func NewContent(h *hugolib.HugoSites, kind, targetPath string) error {
kind: kind,
targetPath: targetPath,
+ force: force,
}
ext := paths.Ext(targetPath)
@@ -132,6 +133,7 @@ type contentBuilder struct {
kind string
isDir bool
dirMap archetypeMap
+ force bool
}
func (b *contentBuilder) buildDir() error {
@@ -145,7 +147,7 @@ func (b *contentBuilder) buildDir() error {
for _, fi := range b.dirMap.contentFiles {
targetFilename := filepath.Join(b.targetPath, strings.TrimPrefix(fi.Meta().Path, b.archetypeFilename))
- abs, err := b.cf.CreateContentPlaceHolder(targetFilename)
+ abs, err := b.cf.CreateContentPlaceHolder(targetFilename, b.force)
if err != nil {
return err
}
@@ -218,7 +220,7 @@ func (b *contentBuilder) buildDir() error {
}
func (b *contentBuilder) buildFile() (string, error) {
- contentPlaceholderAbsFilename, err := b.cf.CreateContentPlaceHolder(b.targetPath)
+ contentPlaceholderAbsFilename, err := b.cf.CreateContentPlaceHolder(b.targetPath, b.force)
if err != nil {
return "", err
}