1

fix absolute plugin usage

This commit is contained in:
Alex Yatskov 2019-02-27 09:18:28 -08:00
parent c004f4f6fc
commit 61a4b118e0

View File

@ -6,7 +6,6 @@ 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/absolute" "github.com/FooSoft/goldsmith-components/plugins/absolute"
"github.com/FooSoft/goldsmith-components/plugins/breadcrumbs" "github.com/FooSoft/goldsmith-components/plugins/breadcrumbs"
"github.com/FooSoft/goldsmith-components/plugins/collection" "github.com/FooSoft/goldsmith-components/plugins/collection"
@ -36,9 +35,7 @@ func fixup(doc *goquery.Document) error {
return nil return nil
} }
type builder struct { type builder struct{}
root string
}
func (b *builder) Build(contentDir, buildDir, cacheDir string) { func (b *builder) Build(contentDir, buildDir, cacheDir string) {
tagMeta := map[string]interface{}{ tagMeta := map[string]interface{}{
@ -64,9 +61,7 @@ func (b *builder) Build(contentDir, buildDir, cacheDir string) {
Chain(syntax.New().Placement(syntax.PlaceInline)). Chain(syntax.New().Placement(syntax.PlaceInline)).
Chain(document.New(fixup)). Chain(document.New(fixup)).
Chain(thumbnail.New()). Chain(thumbnail.New()).
FilterPush(condition.New(len(b.root) > 0)). Chain(absolute.New()).
Chain(absolute.New().BaseUrl(b.root)).
FilterPop().
End(buildDir) End(buildDir)
for _, err := range errs { for _, err := range errs {
@ -75,9 +70,8 @@ func (b *builder) Build(contentDir, buildDir, cacheDir string) {
} }
func main() { func main() {
root := flag.String("root", "", "server root")
port := flag.Int("port", 8080, "server port") port := flag.Int("port", 8080, "server port")
flag.Parse() flag.Parse()
devserver.DevServe(&builder{*root}, *port, "content", "build", "cache") devserver.DevServe(new(builder), *port, "content", "build", "cache")
} }