Fix file paths
This commit is contained in:
parent
d990d67e42
commit
1df5053417
22
main.go
22
main.go
@ -32,8 +32,9 @@ var githubStyle string
|
|||||||
var githubFixup string
|
var githubFixup string
|
||||||
|
|
||||||
type builder struct {
|
type builder struct {
|
||||||
port int
|
port int
|
||||||
browsing bool
|
path string
|
||||||
|
open bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func embedCss(file *goldsmith.File, doc *goquery.Document) error {
|
func embedCss(file *goldsmith.File, doc *goquery.Document) error {
|
||||||
@ -69,9 +70,9 @@ func (self *builder) Build(contentDir, buildDir, cacheDir string) {
|
|||||||
log.Print(err)
|
log.Print(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.browsing {
|
if !self.open {
|
||||||
webbrowser.Open(fmt.Sprintf("http://127.0.0.1:%d", self.port))
|
webbrowser.Open(fmt.Sprintf("http://127.0.0.1:%d/%s", self.port, self.path))
|
||||||
self.browsing = true
|
self.open = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,8 +90,17 @@ func main() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var contentName string
|
||||||
contentDir := requestPath
|
contentDir := requestPath
|
||||||
if !info.IsDir() {
|
if !info.IsDir() {
|
||||||
|
contentName = filepath.Base(requestPath)
|
||||||
|
contentExt := filepath.Ext(contentName)
|
||||||
|
switch contentExt {
|
||||||
|
case ".md", ".markdown":
|
||||||
|
contentName = strings.TrimSuffix(contentName, contentExt)
|
||||||
|
contentName += ".html"
|
||||||
|
}
|
||||||
|
|
||||||
contentDir = filepath.Dir(requestPath)
|
contentDir = filepath.Dir(requestPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +117,7 @@ func main() {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
b := &builder{port: *port}
|
b := &builder{port: *port, path: contentName}
|
||||||
devserver.DevServe(b, *port, contentDir, buildDir, "")
|
devserver.DevServe(b, *port, contentDir, buildDir, "")
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user