parent
e908d955d2
commit
fd924d1802
|
@ -152,10 +152,11 @@ func NewContent(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func doNewSite(fs *hugofs.Fs, basepath string, force bool) error {
|
func doNewSite(fs *hugofs.Fs, basepath string, force bool) error {
|
||||||
|
archeTypePath := filepath.Join(basepath, "archetypes")
|
||||||
dirs := []string{
|
dirs := []string{
|
||||||
filepath.Join(basepath, "layouts"),
|
filepath.Join(basepath, "layouts"),
|
||||||
filepath.Join(basepath, "content"),
|
filepath.Join(basepath, "content"),
|
||||||
filepath.Join(basepath, "archetypes"),
|
archeTypePath,
|
||||||
filepath.Join(basepath, "static"),
|
filepath.Join(basepath, "static"),
|
||||||
filepath.Join(basepath, "data"),
|
filepath.Join(basepath, "data"),
|
||||||
filepath.Join(basepath, "themes"),
|
filepath.Join(basepath, "themes"),
|
||||||
|
@ -190,6 +191,10 @@ func doNewSite(fs *hugofs.Fs, basepath string, force bool) error {
|
||||||
|
|
||||||
createConfig(fs, basepath, configFormat)
|
createConfig(fs, basepath, configFormat)
|
||||||
|
|
||||||
|
// Create a defaul archetype file.
|
||||||
|
helpers.SafeWriteToDisk(filepath.Join(archeTypePath, "default.md"),
|
||||||
|
strings.NewReader(create.ArchetypeTemplateTemplate), fs.Source)
|
||||||
|
|
||||||
jww.FEEDBACK.Printf("Congratulations! Your new Hugo site is created in %s.\n\n", basepath)
|
jww.FEEDBACK.Printf("Congratulations! Your new Hugo site is created in %s.\n\n", basepath)
|
||||||
jww.FEEDBACK.Println(nextStepsText())
|
jww.FEEDBACK.Println(nextStepsText())
|
||||||
|
|
||||||
|
|
|
@ -48,11 +48,13 @@ type ArchetypeFileData struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
archetypeTemplateTemplate = `---
|
ArchetypeTemplateTemplate = `---
|
||||||
title: "{{ replace .TranslationBaseName "-" " " | title }}"
|
title: "{{ replace .TranslationBaseName "-" " " | title }}"
|
||||||
date: {{ .Date }}
|
date: {{ .Date }}
|
||||||
draft: true
|
draft: true
|
||||||
---`
|
---
|
||||||
|
|
||||||
|
`
|
||||||
)
|
)
|
||||||
|
|
||||||
func executeArcheTypeAsTemplate(s *hugolib.Site, kind, targetPath, archetypeFilename string) ([]byte, error) {
|
func executeArcheTypeAsTemplate(s *hugolib.Site, kind, targetPath, archetypeFilename string) ([]byte, error) {
|
||||||
|
@ -75,7 +77,7 @@ func executeArcheTypeAsTemplate(s *hugolib.Site, kind, targetPath, archetypeFile
|
||||||
|
|
||||||
if archetypeFilename == "" {
|
if archetypeFilename == "" {
|
||||||
// TODO(bep) archetype revive the issue about wrong tpl funcs arg order
|
// TODO(bep) archetype revive the issue about wrong tpl funcs arg order
|
||||||
archetypeTemplate = []byte(archetypeTemplateTemplate)
|
archetypeTemplate = []byte(ArchetypeTemplateTemplate)
|
||||||
} else {
|
} else {
|
||||||
archetypeTemplate, err = afero.ReadFile(s.Fs.Source, archetypeFilename)
|
archetypeTemplate, err = afero.ReadFile(s.Fs.Source, archetypeFilename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -105,7 +107,7 @@ func executeArcheTypeAsTemplate(s *hugolib.Site, kind, targetPath, archetypeFile
|
||||||
s.Log.FEEDBACK.Println(fmt.Sprintf(`WARNING: date and/or title missing from archetype file %q.
|
s.Log.FEEDBACK.Println(fmt.Sprintf(`WARNING: date and/or title missing from archetype file %q.
|
||||||
From Hugo 0.24 this must be provided in the archetype file itself, if needed. Example:
|
From Hugo 0.24 this must be provided in the archetype file itself, if needed. Example:
|
||||||
%s
|
%s
|
||||||
`, archetypeFilename, archetypeTemplateTemplate))
|
`, archetypeFilename, ArchetypeTemplateTemplate))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue