all repos — homestead @ acb17eefc62414e4c1cd6061e0293873a1a9c13c

Code for my website

enable configuration of static files to be copied

Alan Pearce
commit

acb17eefc62414e4c1cd6061e0293873a1a9c13c

parent

8efa0c0335cf673ce530785591f22d5f5ab5259d

3 files changed, 20 insertions(+), 9 deletions(-)

changed files
M domain/content/builder/builder.godomain/content/builder/builder.go
@@ -84,9 +84,10 @@ }
log.Debug("reading posts", "source", options.Source) cc, err := content.NewContentCollection(&content.Config{ - Root: options.Source, - PostDir: postDir, - Repo: options.Repo, + Root: options.Source, + PostDir: postDir, + Repo: options.Repo, + StaticFiles: config.StaticFiles, }, log.Named("content")) if err != nil { return fault.Wrap(err)
M domain/content/posts.godomain/content/posts.go
@@ -42,9 +42,10 @@ content []byte
} type Config struct { - Root string - PostDir string - Repo *vcs.Repository + Root string + PostDir string + Repo *vcs.Repository + StaticFiles []string } type Collection struct {
@@ -68,7 +69,6 @@ ".md", "",
) StaticList = []string{ "config.toml", - "cv.html", "public_key.asc", } )
@@ -104,6 +104,8 @@ return buf.String(), nil
} func NewContentCollection(config *Config, log *log.Logger) (*Collection, error) { + config.StaticFiles = append(config.StaticFiles, StaticList...) + cc := &Collection{ Posts: []*Post{}, Tags: mapset.NewSet[string](),
@@ -138,6 +140,7 @@
return cc, nil } func (cc *Collection) HandleFile(filename string, d fs.DirEntry) error { + ext := strings.TrimPrefix(filepath.Ext(filename), ".") switch { case strings.HasPrefix(filename, ".") && filename != "." &&
@@ -148,7 +151,8 @@ if d.Type().IsDir() {
return fs.SkipDir } case !d.Type().IsDir(): - if filepath.Ext(filename) == ".md" { + switch ext { + case "md": if strings.HasPrefix(filename, cc.config.PostDir) { post, err := cc.GetPost(filename) if err != nil {
@@ -166,8 +170,12 @@ return err
} cc.Pages = append(cc.Pages, page) } - } else if slices.Contains(StaticList, filename) { + case "html": cc.StaticFiles = append(cc.StaticFiles, filename) + default: + if slices.Contains(cc.config.StaticFiles, filename) { + cc.StaticFiles = append(cc.StaticFiles, filename) + } } }
M shared/config/config.goshared/config/config.go
@@ -62,6 +62,8 @@ Taxonomies []Taxonomy
Menu []MenuItem RelMe []MenuItem `toml:"rel_me"` + StaticFiles []string `toml:"static_files"` + Go GoPackagesConfig }