go fmt
Anirudh Oppiliappan x@icyphox.sh
Fri, 30 Oct 2020 12:02:19 +0530
3 files changed,
53 insertions(+),
53 deletions(-)
M
build.go
→
build.go
@@ -1,12 +1,12 @@
package main import ( + "github.com/cross-cpm/go-shutil" "io/ioutil" "os" "path/filepath" "strings" "text/template" - "github.com/cross-cpm/go-shutil" ) func processTemplate(tmplPath string) *template.Template {@@ -29,16 +29,16 @@ restContent, fm := parseFrontmatter(content)
bodyHtml := mdRender(restContent) relPath, _ := filepath.Rel("pages/", mdPath) - var buildPath string - if strings.HasSuffix(relPath, "_index.md") { - dir, _ := filepath.Split(relPath) - buildPath = filepath.Join("build", dir) - } else { - buildPath = filepath.Join( - "build", - strings.TrimSuffix(relPath, filepath.Ext(relPath)), - ) - } + var buildPath string + if strings.HasSuffix(relPath, "_index.md") { + dir, _ := filepath.Split(relPath) + buildPath = filepath.Join("build", dir) + } else { + buildPath = filepath.Join( + "build", + strings.TrimSuffix(relPath, filepath.Ext(relPath)), + ) + } os.MkdirAll(buildPath, 0755) fm.Body = string(bodyHtml)@@ -48,9 +48,9 @@ if err != nil {
printErr(err) return } - if fm.Template == "" { - fm.Template = "text.html" - } + if fm.Template == "" { + fm.Template = "text.html" + } tmpl := processTemplate(fm.Template) err = tmpl.Execute(htmlFile, fm) if err != nil {@@ -66,33 +66,33 @@ if err != nil {
printErr(err) return err } - if filepath.Ext(path) == ".md" { - handleMd(path) - } else { - f, err := os.Stat(path) - if err != nil { - printErr(err) - } - mode := f.Mode() - if mode.IsRegular() { - options := shutil.CopyOptions{} - relPath, _ := filepath.Rel("pages/", path) - options.FollowSymlinks = true - shutil.CopyFile( - path, - filepath.Join("build", relPath), - &options, - ) - } - } + if filepath.Ext(path) == ".md" { + handleMd(path) + } else { + f, err := os.Stat(path) + if err != nil { + printErr(err) + } + mode := f.Mode() + if mode.IsRegular() { + options := shutil.CopyOptions{} + relPath, _ := filepath.Rel("pages/", path) + options.FollowSymlinks = true + shutil.CopyFile( + path, + filepath.Join("build", relPath), + &options, + ) + } + } return nil }) if err != nil { printErr(err) } - _, err = shutil.CopyTree("static", filepath.Join("build", "static"), nil) - if err != nil { - printErr(err) - } + _, err = shutil.CopyTree("static", filepath.Join("build", "static"), nil) + if err != nil { + printErr(err) + } }
M
main.go
→
main.go
@@ -18,11 +18,11 @@ build builds the current project
new PATH create a new markdown post ` - // TODO: make arg parsing less shit + // TODO: make arg parsing less shit - if len(args) <= 1 { - fmt.Println(helpStr) - } + if len(args) <= 1 { + fmt.Println(helpStr) + } switch args[1] { case "init":
M
markdown.go
→
markdown.go
@@ -1,8 +1,8 @@
package main import ( + bfc "github.com/Depado/bfchroma" bf "github.com/russross/blackfriday/v2" - bfc "github.com/Depado/bfchroma" ) var bfFlags = bf.UseXHTML | bf.Smartypants | bf.SmartypantsFractions |@@ -10,16 +10,16 @@ bf.SmartypantsDashes | bf.NofollowLinks | bf.FootnoteReturnLinks
func mdRender(input []byte) []byte { return bf.Run( - input, - bf.WithRenderer( - bfc.NewRenderer( - bfc.Style("bw"), - bfc.Extend( - bf.NewHTMLRenderer(bf.HTMLRendererParameters{ - Flags: bfFlags, - }), - ), - ), - ), + input, + bf.WithRenderer( + bfc.NewRenderer( + bfc.Style("bw"), + bfc.Extend( + bf.NewHTMLRenderer(bf.HTMLRendererParameters{ + Flags: bfFlags, + }), + ), + ), + ), ) }