do not copy config.yml
This commit is contained in:
parent
1fecb5faae
commit
7dbaa95a90
28
main.go
28
main.go
@ -101,6 +101,16 @@ type PathConfigTree struct {
|
|||||||
|
|
||||||
var contentConfig = new(PathConfigTree)
|
var contentConfig = new(PathConfigTree)
|
||||||
|
|
||||||
|
func backToRoot(curNavPath string) string {
|
||||||
|
tmpPath := ""
|
||||||
|
if curNavPath != "" {
|
||||||
|
for i := strings.Count(curNavPath, "/") + 1; i > 0; i-- {
|
||||||
|
tmpPath += "../"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tmpPath
|
||||||
|
}
|
||||||
|
|
||||||
func readContentDir(inBase string, outBase string, dir string, conf *PathConfig, tree *PathConfigTree) {
|
func readContentDir(inBase string, outBase string, dir string, conf *PathConfig, tree *PathConfigTree) {
|
||||||
inPath := inBase
|
inPath := inBase
|
||||||
if dir != "" {
|
if dir != "" {
|
||||||
@ -172,7 +182,7 @@ func readContentDir(inBase string, outBase string, dir string, conf *PathConfig,
|
|||||||
// first only files
|
// first only files
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
p := inPath + "/" + f.Name()
|
p := inPath + "/" + f.Name()
|
||||||
if !f.IsDir() {
|
if !f.IsDir() && f.Name() != "config.yml" {
|
||||||
switch path.Ext(f.Name()) {
|
switch path.Ext(f.Name()) {
|
||||||
case ".md":
|
case ".md":
|
||||||
log.Debugf(".MD %s", p)
|
log.Debugf(".MD %s", p)
|
||||||
@ -274,11 +284,8 @@ func buildNavigation(conf *PathConfigTree, curNavMap *map[string]*navElement, cu
|
|||||||
|
|
||||||
if activeNav != "" && activeNav != "/" {
|
if activeNav != "" && activeNav != "/" {
|
||||||
// calculate relative path
|
// calculate relative path
|
||||||
tmpPath := ""
|
bToRoot := backToRoot(activeNav)
|
||||||
for i := len(strings.Split(activeNav, "/")); i > 0; i-- {
|
navEl.GoTo = bToRoot + navEl.GoTo
|
||||||
tmpPath += "../"
|
|
||||||
}
|
|
||||||
navEl.GoTo = tmpPath + navEl.GoTo
|
|
||||||
navEl.GoTo = path.Clean(navEl.GoTo)
|
navEl.GoTo = path.Clean(navEl.GoTo)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,18 +443,13 @@ func processContent(conf *PathConfigTree) {
|
|||||||
|
|
||||||
if find := globalConfig.Assets.FixTemplate.Find; find != "" {
|
if find := globalConfig.Assets.FixTemplate.Find; find != "" {
|
||||||
log.Debugf("fixing assets paths in '%s' for '%s'", templateFile, inFile)
|
log.Debugf("fixing assets paths in '%s' for '%s'", templateFile, inFile)
|
||||||
tmpPath := ""
|
bToRoot := backToRoot(curNavPath)
|
||||||
if curNavPath != "" {
|
|
||||||
for i := len(strings.Split(curNavPath, "/")); i > 0; i-- {
|
|
||||||
tmpPath += "../"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
regex, err := regexp.Compile(find)
|
regex, err := regexp.Compile(find)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("could not compile regexp '%s' for assets path: %s", find, err)
|
log.Panicf("could not compile regexp '%s' for assets path: %s", find, err)
|
||||||
}
|
}
|
||||||
repl := globalConfig.Assets.FixTemplate.Replace
|
repl := globalConfig.Assets.FixTemplate.Replace
|
||||||
repl = tmpPath + globalConfig.Assets.ToPath + "/" + repl
|
repl = bToRoot + globalConfig.Assets.ToPath + "/" + repl
|
||||||
repl = path.Clean(repl) + "/"
|
repl = path.Clean(repl) + "/"
|
||||||
log.Debugf("new assets paths: %s", repl)
|
log.Debugf("new assets paths: %s", repl)
|
||||||
result = regex.ReplaceAllString(result, repl)
|
result = regex.ReplaceAllString(result, repl)
|
||||||
|
Loading…
Reference in New Issue
Block a user