Skip to content

Commit bb4e66c

Browse files
create: Fix new content command with future dates
Fixes #12599
1 parent 45ec2f8 commit bb4e66c

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

‎commands/new.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ Ensure you run this within the root directory of your site.`,
5353
if len(args) < 1 {
5454
return newUserError("path needs to be provided")
5555
}
56-
h, err := r.Hugo(flagsToCfg(cd, nil))
56+
cfg := flagsToCfg(cd, nil)
57+
cfg.Set("BuildFuture", true)
58+
h, err := r.Hugo(cfg)
5759
if err != nil {
5860
return err
5961
}

‎testscripts/commands/new_content.txt‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,24 @@ hugo new content --kind post post/first-post.md
44
! exists resources
55
grep 'draft = true' content/post/first-post.md
66

7+
# Issue 12599
8+
cd $WORK
79

10+
hugo new site --format toml --force issue-12599
11+
cp hugo.toml issue-12599/hugo.toml
12+
cd issue-12599
13+
hugo new content content/s1/2099-12-31-p1.md
14+
hugo -DF
15+
grep 'DATE _2099-12-31_' public/s1/p1/index.html
16+
grep 'SLUG _p1_' public/s1/p1/index.html
17+
grep 'TITLE _2099 12 31 P1_' public/s1/p1/index.html
18+
19+
-- hugo.toml --
20+
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
21+
[frontmatter]
22+
date = [':filename', ':default']
23+
publishDate = [':filename', ':default']
24+
-- issue-12599/layouts/all.html --
25+
DATE _{{ .Date.Format "2006-01-02" }}_
26+
SLUG _{{ .Slug }}_
27+
TITLE _{{ .Title }}_

0 commit comments

Comments
 (0)