lint some stuff
This commit is contained in:
parent
8ed78288a7
commit
acc4c92b15
|
@ -32,7 +32,8 @@ func ServeHTTP(w http.ResponseWriter, r *http.Request, code int, err error) (int
|
||||||
"Defined": variables.Defined,
|
"Defined": variables.Defined,
|
||||||
}
|
}
|
||||||
|
|
||||||
tpl, err := templates.Get(r, functions, "error")
|
var tpl *template.Template
|
||||||
|
tpl, err = templates.Get(r, functions, "error")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
|
|
|
@ -11,7 +11,11 @@ import (
|
||||||
"github.com/spf13/hugo/parser"
|
"github.com/spf13/hugo/parser"
|
||||||
)
|
)
|
||||||
|
|
||||||
const mainName = "#MAIN#"
|
const (
|
||||||
|
mainName = "#MAIN#"
|
||||||
|
objectType = "object"
|
||||||
|
arrayType = "array"
|
||||||
|
)
|
||||||
|
|
||||||
var mainTitle = ""
|
var mainTitle = ""
|
||||||
|
|
||||||
|
@ -25,7 +29,7 @@ func Pretty(content []byte) (interface{}, string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
object := new(frontmatter)
|
object := new(frontmatter)
|
||||||
object.Type = "object"
|
object.Type = objectType
|
||||||
object.Name = mainName
|
object.Name = mainName
|
||||||
|
|
||||||
return rawToPretty(front, object), mainTitle, nil
|
return rawToPretty(front, object), mainTitle, nil
|
||||||
|
@ -95,12 +99,12 @@ func (f sortByTitle) Less(i, j int) bool {
|
||||||
func handleObjects(content interface{}, parent *frontmatter, name string) *frontmatter {
|
func handleObjects(content interface{}, parent *frontmatter, name string) *frontmatter {
|
||||||
c := new(frontmatter)
|
c := new(frontmatter)
|
||||||
c.Parent = parent
|
c.Parent = parent
|
||||||
c.Type = "object"
|
c.Type = objectType
|
||||||
c.Title = name
|
c.Title = name
|
||||||
|
|
||||||
if parent.Name == mainName {
|
if parent.Name == mainName {
|
||||||
c.Name = c.Title
|
c.Name = c.Title
|
||||||
} else if parent.Type == "array" {
|
} else if parent.Type == arrayType {
|
||||||
c.Name = parent.Name + "[]"
|
c.Name = parent.Name + "[]"
|
||||||
} else {
|
} else {
|
||||||
c.Name = parent.Name + "[" + c.Title + "]"
|
c.Name = parent.Name + "[" + c.Title + "]"
|
||||||
|
@ -113,7 +117,7 @@ func handleObjects(content interface{}, parent *frontmatter, name string) *front
|
||||||
func handleArrays(content interface{}, parent *frontmatter, name string) *frontmatter {
|
func handleArrays(content interface{}, parent *frontmatter, name string) *frontmatter {
|
||||||
c := new(frontmatter)
|
c := new(frontmatter)
|
||||||
c.Parent = parent
|
c.Parent = parent
|
||||||
c.Type = "array"
|
c.Type = arrayType
|
||||||
c.Title = name
|
c.Title = name
|
||||||
|
|
||||||
if parent.Name == mainName {
|
if parent.Name == mainName {
|
||||||
|
@ -151,10 +155,10 @@ func handleFlatValues(content interface{}, parent *frontmatter, name string) *fr
|
||||||
c.HTMLType = "text"
|
c.HTMLType = "text"
|
||||||
}
|
}
|
||||||
|
|
||||||
if parent.Type == "array" {
|
if parent.Type == arrayType {
|
||||||
c.Name = parent.Name + "[]"
|
c.Name = parent.Name + "[]"
|
||||||
c.Title = content.(string)
|
c.Title = content.(string)
|
||||||
} else if parent.Type == "object" {
|
} else if parent.Type == objectType {
|
||||||
c.Title = name
|
c.Title = name
|
||||||
c.Name = parent.Name + "[" + name + "]"
|
c.Name = parent.Name + "[" + name + "]"
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ func GetPath() string {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// Check if Hugo is already on $PATH
|
// Check if Hugo is already on $PATH
|
||||||
if hugo, err := exec.LookPath("hugo"); err == nil {
|
if hugo, err = exec.LookPath("hugo"); err == nil {
|
||||||
return hugo
|
return hugo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue