Fix file paths
This commit is contained in:
parent
d990d67e42
commit
1df5053417
20
main.go
20
main.go
@ -33,7 +33,8 @@ var githubFixup string
|
||||
|
||||
type builder struct {
|
||||
port int
|
||||
browsing bool
|
||||
path string
|
||||
open bool
|
||||
}
|
||||
|
||||
func embedCss(file *goldsmith.File, doc *goquery.Document) error {
|
||||
@ -69,9 +70,9 @@ func (self *builder) Build(contentDir, buildDir, cacheDir string) {
|
||||
log.Print(err)
|
||||
}
|
||||
|
||||
if !self.browsing {
|
||||
webbrowser.Open(fmt.Sprintf("http://127.0.0.1:%d", self.port))
|
||||
self.browsing = true
|
||||
if !self.open {
|
||||
webbrowser.Open(fmt.Sprintf("http://127.0.0.1:%d/%s", self.port, self.path))
|
||||
self.open = true
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,8 +90,17 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
var contentName string
|
||||
contentDir := requestPath
|
||||
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)
|
||||
}
|
||||
|
||||
@ -107,7 +117,7 @@ func main() {
|
||||
}()
|
||||
|
||||
go func() {
|
||||
b := &builder{port: *port}
|
||||
b := &builder{port: *port, path: contentName}
|
||||
devserver.DevServe(b, *port, contentDir, buildDir, "")
|
||||
}()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user