mirror of
https://github.com/gohugoio/hugo.git
synced 2025-09-08 23:40:40 +02:00
Add directory based archetypes
Given this content: ```bash archetypes ├── default.md └── post-bundle ├── bio.md ├── images │ └── featured.jpg └── index.md ``` ```bash hugo new --kind post-bundle post/my-post ``` Will create a new folder in `/content/post/my-post` with the same set of files as in the `post-bundle` archetypes folder. This commit also improves the archetype language detection, so, if you use template code in your content files, the `.Site` you get is for the correct language. This also means that it is now possible to translate strings defined in the `i18n` bundles, e.g. `{{ i18n "hello" }}`. Fixes #4535
This commit is contained in:
@@ -61,7 +61,7 @@ func (fi *fileInfo) isOwner() bool {
|
||||
return fi.bundleTp > bundleNot
|
||||
}
|
||||
|
||||
func isContentFile(filename string) bool {
|
||||
func IsContentFile(filename string) bool {
|
||||
return contentFileExtensionsSet[strings.TrimPrefix(helpers.Ext(filename), ".")]
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ const (
|
||||
// Returns the given file's name's bundle type and whether it is a content
|
||||
// file or not.
|
||||
func classifyBundledFile(name string) (bundleDirType, bool) {
|
||||
if !isContentFile(name) {
|
||||
if !IsContentFile(name) {
|
||||
return bundleNot, false
|
||||
}
|
||||
if strings.HasPrefix(name, "_index.") {
|
||||
|
@@ -57,6 +57,14 @@ func (h *HugoSites) IsMultihost() bool {
|
||||
return h != nil && h.multihost
|
||||
}
|
||||
|
||||
func (h *HugoSites) LanguageSet() map[string]bool {
|
||||
set := make(map[string]bool)
|
||||
for _, s := range h.Sites {
|
||||
set[s.Language.Lang] = true
|
||||
}
|
||||
return set
|
||||
}
|
||||
|
||||
func (h *HugoSites) NumLogErrors() int {
|
||||
if h == nil {
|
||||
return 0
|
||||
|
@@ -76,7 +76,7 @@ func newCapturer(
|
||||
isBundleHeader := func(filename string) bool {
|
||||
base := filepath.Base(filename)
|
||||
name := helpers.Filename(base)
|
||||
return isContentFile(base) && (name == "index" || name == "_index")
|
||||
return IsContentFile(base) && (name == "index" || name == "_index")
|
||||
}
|
||||
|
||||
// Make sure that any bundle header files are processed before the others. This makes
|
||||
|
@@ -795,7 +795,7 @@ func (s *Site) processPartial(events []fsnotify.Event) (whatChanged, error) {
|
||||
removed = true
|
||||
}
|
||||
}
|
||||
if removed && isContentFile(ev.Name) {
|
||||
if removed && IsContentFile(ev.Name) {
|
||||
h.removePageByFilename(ev.Name)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user