slug for output directories
All checks were successful
the build was successful

This commit is contained in:
Sebastian Frank 2019-02-14 14:42:46 +01:00
parent 1d3facc319
commit 1fecb5faae
Signed by: apairon
GPG Key ID: 7270D06DDA7FE8C3
6 changed files with 16 additions and 7 deletions

6
.gitmodules vendored
View File

@ -40,3 +40,9 @@
[submodule "vendor/github.com/juju/errors"]
path = vendor/github.com/juju/errors
url = https://github.com/juju/errors
[submodule "vendor/github.com/gosimple/slug"]
path = vendor/github.com/gosimple/slug
url = https://github.com/gosimple/slug
[submodule "vendor/github.com/rainycape/unidecode"]
path = vendor/github.com/rainycape/unidecode
url = https://github.com/rainycape/unidecode

View File

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

15
main.go
View File

@ -12,6 +12,7 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/flosch/pongo2"
"github.com/gosimple/slug"
"github.com/op/go-logging"
cpy "github.com/otiai10/copy"
"gopkg.in/russross/blackfriday.v2"
@ -155,19 +156,19 @@ func readContentDir(inBase string, outBase string, dir string, conf *PathConfig,
stripedDir = regex.ReplaceAllString(stripedDir, "$1")
}
}
regex := regexp.MustCompile("[^a-zA-Z]")
stripedDir = regex.ReplaceAllString(stripedDir, "_")
outPath := outBase + "/" + stripedDir
outPath = path.Clean(outPath)
log.Infof("calculated output directory: %s", outPath)
tree.OutputPath = outPath
if tree.Config.This.Navname == nil {
navname := strings.Replace(stripedDir, "_", " ", -1)
tree.Config.This.Navname = &navname
}
stripedDir = slug.Make(stripedDir)
outPath := outBase + "/" + stripedDir
outPath = path.Clean(outPath)
log.Infof("calculated output directory: %s", outPath)
tree.OutputPath = outPath
// first only files
for _, f := range files {
p := inPath + "/" + f.Name()

1
vendor/github.com/gosimple/slug generated vendored Submodule

@ -0,0 +1 @@
Subproject commit 42ac18c34c2c6f4843fa48167317dcaa9416d1e2

1
vendor/github.com/rainycape/unidecode generated vendored Submodule

@ -0,0 +1 @@
Subproject commit cb7f23ec59bec0d61b19c56cd88cee3d0cc1870c