update basic sample
This commit is contained in:
parent
375d54dfb3
commit
e8d7c974f0
@ -3,7 +3,6 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{{.Meta.Title}}</title>
|
||||
</head>
|
||||
<body>
|
||||
@ -16,11 +15,7 @@
|
||||
|
||||
{{define "page"}}
|
||||
{{template "header" .}}
|
||||
<div class="container">
|
||||
<div class="page-header">
|
||||
<h1>{{.Meta.Title}}</h1>
|
||||
</div>
|
||||
{{.Meta.Content}}
|
||||
</div>
|
||||
{{template "footer" .}}
|
||||
{{end}}
|
||||
|
@ -6,20 +6,27 @@ import (
|
||||
|
||||
"github.com/FooSoft/goldsmith"
|
||||
"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/layout"
|
||||
"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) {
|
||||
errs := goldsmith.Begin(contentDir).
|
||||
Cache(cacheDir).
|
||||
Chain(frontmatter.New()).
|
||||
Chain(markdown.New()).
|
||||
Chain(layout.New()).
|
||||
End(buildDir)
|
||||
func (b *builder) Build(srcDir, dstDir, cacheDir string) {
|
||||
errs := goldsmith.
|
||||
Begin(srcDir). // read files from srcDir
|
||||
Chain(frontmatter.New()). // extract frontmatter and store it as metadata
|
||||
Chain(markdown.New()). // convert *.md files to *.html files
|
||||
Chain(layout.New()). // apply *.gohtml templates to *.html files
|
||||
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 {
|
||||
log.Print(err)
|
||||
@ -28,7 +35,8 @@ func (b *builder) Build(contentDir, buildDir, cacheDir string) {
|
||||
|
||||
func main() {
|
||||
port := flag.Int("port", 8080, "server port")
|
||||
dist := flag.Bool("dist", false, "final dist mode")
|
||||
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