diff --git a/content.go b/content.go index da44264..a640381 100644 --- a/content.go +++ b/content.go @@ -16,6 +16,10 @@ import ( // ReadContentDir walks through content directory and builds the tree of configurations func (node *TreeNode) ReadContentDir(inBase string, outBase string, dir string, conf *PathConfig) { + if node.root == nil { + // first node is root + node.root = node + } node.fillConfig(inBase, outBase, dir, conf) files, err := ioutil.ReadDir(node.InputPath) @@ -51,6 +55,7 @@ func (node *TreeNode) ReadContentDir(inBase string, outBase string, dir string, if f.IsDir() { helper.Log.Debugf("DIR %s", p) newTree := new(TreeNode) + newTree.root = node.root if node.Sub == nil { node.Sub = make([]*TreeNode, 0) } diff --git a/context.go b/context.go index 5e4dcbc..c309824 100644 --- a/context.go +++ b/context.go @@ -154,10 +154,6 @@ func (node *TreeNode) handleCollections() { } func (node *TreeNode) fillConfig(inBase, outBase, dir string, conf *PathConfig) { - if node.root == nil { - // this must be root - node.root = node - } inPath := inBase if dir != "" { inPath += "/" + dir @@ -229,6 +225,7 @@ func (node *TreeNode) fillConfig(inBase, outBase, dir string, conf *PathConfig) func Add2Nav(currentNode *TreeNode, pathConfig *PathConfig, tplFilename, outDir string, navname string, ctx interface{}, dataMapKey string, body string, hidden bool) { newNode := new(TreeNode) + newNode.root = currentNode.root newNode.fillConfig( currentNode.InputPath, currentNode.OutputPath,