summaryrefslogtreecommitdiffstats
path: root/helpers/path.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-12-14 20:12:03 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-12-15 21:35:38 +0100
commita3a67163f93b4fc16c2cc0343ffb532631ec4c8b (patch)
treef311e311e00c3eaad0b173c79420a5b64fd0e445 /helpers/path.go
parent596bbea815f9215bc08806c30183631278318251 (diff)
hugolib: Enable override of theme base template only
This commit fixes the base template lookup order to match the behaviour of regular templates. ``` 1. <current-path>/<template-name>-baseof.<suffix>, e.g. list-baseof.<suffix>. 2. <current-path>/baseof.<suffix> 3. _default/<template-name>-baseof.<suffix>, e.g. list-baseof.<suffix>. 4. _default/baseof.<suffix> For each of the steps above, it will first look in the project, then, if theme is set, in the theme's layouts folder. ``` Fixes #2783
Diffstat (limited to 'helpers/path.go')
-rw-r--r--helpers/path.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/helpers/path.go b/helpers/path.go
index 6a35a55ca..7dea0b0dd 100644
--- a/helpers/path.go
+++ b/helpers/path.go
@@ -157,6 +157,12 @@ func AbsPathify(inPath string) string {
return filepath.Clean(filepath.Join(viper.GetString("workingDir"), inPath))
}
+// GetLayoutDirPath returns the absolute path to the layout file dir
+// for the current Hugo project.
+func GetLayoutDirPath() string {
+ return AbsPathify(viper.GetString("layoutDir"))
+}
+
// GetStaticDirPath returns the absolute path to the static file dir
// for the current Hugo project.
func GetStaticDirPath() string {
@@ -172,6 +178,15 @@ func GetThemeDir() string {
return ""
}
+// GetRelativeThemeDir gets the relative root directory of the current theme, if there is one.
+// If there is no theme, returns the empty string.
+func GetRelativeThemeDir() string {
+ if ThemeSet() {
+ return strings.TrimPrefix(filepath.Join(viper.GetString("themesDir"), viper.GetString("theme")), FilePathSeparator)
+ }
+ return ""
+}
+
// GetThemeStaticDirPath returns the theme's static dir path if theme is set.
// If theme is set and the static dir doesn't exist, an error is returned.
func GetThemeStaticDirPath() (string, error) {