update basic sample
This commit is contained in:
parent
375d54dfb3
commit
e8d7c974f0
@ -3,7 +3,6 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<title>{{.Meta.Title}}</title>
|
<title>{{.Meta.Title}}</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -16,11 +15,7 @@
|
|||||||
|
|
||||||
{{define "page"}}
|
{{define "page"}}
|
||||||
{{template "header" .}}
|
{{template "header" .}}
|
||||||
<div class="container">
|
|
||||||
<div class="page-header">
|
|
||||||
<h1>{{.Meta.Title}}</h1>
|
<h1>{{.Meta.Title}}</h1>
|
||||||
</div>
|
|
||||||
{{.Meta.Content}}
|
{{.Meta.Content}}
|
||||||
</div>
|
|
||||||
{{template "footer" .}}
|
{{template "footer" .}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -6,20 +6,27 @@ import (
|
|||||||
|
|
||||||
"github.com/FooSoft/goldsmith"
|
"github.com/FooSoft/goldsmith"
|
||||||
"github.com/FooSoft/goldsmith-components/devserver"
|
"github.com/FooSoft/goldsmith-components/devserver"
|
||||||
|
"github.com/FooSoft/goldsmith-components/filters/condition"
|
||||||
"github.com/FooSoft/goldsmith-components/plugins/frontmatter"
|
"github.com/FooSoft/goldsmith-components/plugins/frontmatter"
|
||||||
"github.com/FooSoft/goldsmith-components/plugins/layout"
|
"github.com/FooSoft/goldsmith-components/plugins/layout"
|
||||||
"github.com/FooSoft/goldsmith-components/plugins/markdown"
|
"github.com/FooSoft/goldsmith-components/plugins/markdown"
|
||||||
|
"github.com/FooSoft/goldsmith-components/plugins/minify"
|
||||||
)
|
)
|
||||||
|
|
||||||
type builder struct{}
|
type builder struct {
|
||||||
|
dist bool
|
||||||
|
}
|
||||||
|
|
||||||
func (b *builder) Build(contentDir, buildDir, cacheDir string) {
|
func (b *builder) Build(srcDir, dstDir, cacheDir string) {
|
||||||
errs := goldsmith.Begin(contentDir).
|
errs := goldsmith.
|
||||||
Cache(cacheDir).
|
Begin(srcDir). // read files from srcDir
|
||||||
Chain(frontmatter.New()).
|
Chain(frontmatter.New()). // extract frontmatter and store it as metadata
|
||||||
Chain(markdown.New()).
|
Chain(markdown.New()). // convert *.md files to *.html files
|
||||||
Chain(layout.New()).
|
Chain(layout.New()). // apply *.gohtml templates to *.html files
|
||||||
End(buildDir)
|
FilterPush(condition.New(b.dist)). // push a dist-only conditional filter onto the stack
|
||||||
|
Chain(minify.New()). // minify *.html, *.css, *.js, etc. files
|
||||||
|
FilterPop(). // pop off the last filter pushed onto the stack
|
||||||
|
End(dstDir) // write files to dstDir
|
||||||
|
|
||||||
for _, err := range errs {
|
for _, err := range errs {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
@ -28,7 +35,8 @@ func (b *builder) Build(contentDir, buildDir, cacheDir string) {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
port := flag.Int("port", 8080, "server port")
|
port := flag.Int("port", 8080, "server port")
|
||||||
|
dist := flag.Bool("dist", false, "final dist mode")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
devserver.DevServe(new(builder), *port, "content", "build", "cache")
|
devserver.DevServe(&builder{*dist}, *port, "content", "build", "cache")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user