From e92528b04c3600739c78195ed474e83db75c77d1 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 14 May 2022 20:52:32 -0700 Subject: [PATCH] Add filters to files to be output --- main.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/main.go b/main.go index 38d6956..e69500f 100644 --- a/main.go +++ b/main.go @@ -14,6 +14,8 @@ import ( "github.com/FooSoft/goldsmith" "github.com/FooSoft/goldsmith-components/devserver" + "github.com/FooSoft/goldsmith-components/filters/operator" + "github.com/FooSoft/goldsmith-components/filters/wildcard" "github.com/FooSoft/goldsmith-components/plugins/document" "github.com/FooSoft/goldsmith-components/plugins/frontmatter" "github.com/FooSoft/goldsmith-components/plugins/livejs" @@ -60,8 +62,24 @@ func (self *builder) Build(contentDir, buildDir, cacheDir string) { goldmark.WithRendererOptions(html.WithUnsafe()), ) + allowedPaths := []string{ + "**/*.gif", + "**/*.html", + "**/*.jpeg", + "**/*.jpg", + "**/*.md", + "**/*.png", + "**/*.svg", + } + + forbiddenPaths := []string{ + "**/.*/**", + } + errs := goldsmith.Begin(contentDir). Clean(true). + FilterPush(wildcard.New(allowedPaths...)). + FilterPush(operator.Not(wildcard.New(forbiddenPaths...))). Chain(frontmatter.New()). Chain(markdown.NewWithGoldmark(gm)). Chain(livejs.New()).