mirror of
https://github.com/gohugoio/hugo.git
synced 2025-05-10 20:59:48 +03:00
Add data files support in themes
If duplicate keys, the main data dir wins. Fixes #892
This commit is contained in:
parent
664fd99135
commit
ebcc1e6699
5 changed files with 100 additions and 46 deletions
|
@ -252,13 +252,13 @@ func copyStatic() error {
|
|||
syncer.SrcFs = hugofs.SourceFs
|
||||
syncer.DestFs = hugofs.DestinationFS
|
||||
|
||||
if themeSet() {
|
||||
themeDir := helpers.AbsPathify("themes/"+viper.GetString("theme")) + "/static/"
|
||||
if _, err := os.Stat(themeDir); os.IsNotExist(err) {
|
||||
jww.ERROR.Println("Unable to find static directory for theme:", viper.GetString("theme"), "in", themeDir)
|
||||
return nil
|
||||
}
|
||||
themeDir, err := helpers.GetThemeStaticDirPath()
|
||||
if err != nil {
|
||||
jww.ERROR.Println(err)
|
||||
return nil
|
||||
}
|
||||
|
||||
if themeDir != "" {
|
||||
// Copy Static to Destination
|
||||
jww.INFO.Println("syncing from", themeDir, "to", publishDir)
|
||||
utils.CheckErr(syncer.Sync(publishDir, themeDir), fmt.Sprintf("Error copying static files of theme to %s", publishDir))
|
||||
|
@ -292,17 +292,13 @@ func getDirList() []string {
|
|||
filepath.Walk(helpers.AbsPathify(viper.GetString("ContentDir")), walker)
|
||||
filepath.Walk(helpers.AbsPathify(viper.GetString("LayoutDir")), walker)
|
||||
filepath.Walk(helpers.AbsPathify(viper.GetString("StaticDir")), walker)
|
||||
if themeSet() {
|
||||
if helpers.ThemeSet() {
|
||||
filepath.Walk(helpers.AbsPathify("themes/"+viper.GetString("theme")), walker)
|
||||
}
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
func themeSet() bool {
|
||||
return viper.GetString("theme") != ""
|
||||
}
|
||||
|
||||
func buildSite(watching ...bool) (err error) {
|
||||
startTime := time.Now()
|
||||
site := &hugolib.Site{}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue