@@ -12,12 +12,13 @@ import (
1212)
1313
1414type CLI struct {
15+ AssetsPath string `help:"path to static assets (default with be source-path/public)"`
16+ BaseURL string `help:"the URL which the contents will be served from, this is only used for generating feeds"`
1517 BuildPath string `help:"where generated content should go" required:"" type:"path"`
18+ FeedGlob string `help:"glob patterns for documents to feature in feeds"`
1619 LayoutFilename string `default:"layout.html" help:"layout file to render" required:""`
1720 Serve bool `help:"serve when done building"`
1821 SourcePath string `help:"source of all files" required:"" type:"path"`
19- AssetsPath string `help:"path to static assets (default with be source-path/public)"`
20- BaseURL string `help:"the URL which the contents will be served from, this is only used for generating feeds"`
2122}
2223
2324func (c * CLI ) Run () error {
@@ -35,15 +36,24 @@ func (c *CLI) Run() error {
3536
3637 markdownGlob := filepath .Join (c .SourcePath , "**" , "*.md" )
3738
38- err := renderer .Execute (markdownGlob )
39+ if c .FeedGlob == "" {
40+ c .FeedGlob = markdownGlob
41+ } else {
42+ c .FeedGlob = filepath .Join (c .SourcePath , c .FeedGlob )
43+ }
44+
45+ err := renderer .Execute (
46+ markdownGlob ,
47+ c .FeedGlob ,
48+ )
3949 if err != nil {
4050 return fmt .Errorf ("could not execute render: %w" , err )
4151 }
4252
4353 if c .Serve {
4454 watcher := NewWatcher (c .SourcePath )
4555
46- go c .startWatcher (watcher , renderer , markdownGlob )
56+ go c .startWatcher (watcher , renderer , markdownGlob , c . FeedGlob )
4757
4858 e := echo .New ()
4959 e .Use (middleware .Logger ())
@@ -62,6 +72,7 @@ func (c *CLI) startWatcher(
6272 watcher * Watcher ,
6373 renderer * Render ,
6474 markdownGlob string ,
75+ feedGlob string ,
6576) {
6677 allGlob := filepath .Join (c .SourcePath , "**" , "{*.md,*.html,*.js,*.css}" )
6778
@@ -71,7 +82,10 @@ func (c *CLI) startWatcher(
7182 if matched {
7283 slog .Info ("rebuilding markdown files" , slog .String ("filename" , filename ))
7384
74- err := renderer .Execute (markdownGlob )
85+ err := renderer .Execute (
86+ markdownGlob ,
87+ feedGlob ,
88+ )
7589 if err != nil {
7690 slog .Error ("could not rebuild markdown files" , slog .String ("error" , err .Error ()))
7791 }
0 commit comments