|
|
|
|
@ -13,6 +13,8 @@ import ( |
|
|
|
|
"strings" |
|
|
|
|
"text/template" |
|
|
|
|
"time" |
|
|
|
|
"regexp" |
|
|
|
|
"slices" |
|
|
|
|
|
|
|
|
|
"github.com/fsnotify/fsnotify" |
|
|
|
|
"github.com/yuin/goldmark" |
|
|
|
|
@ -187,6 +189,17 @@ func SamePath(a string, b string) bool { |
|
|
|
|
return filepath.ToSlash(a) == filepath.ToSlash(b) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func ExcludedPath(fp string) bool { |
|
|
|
|
is_layout := fp == config.Settings.Layout |
|
|
|
|
is_excluded := slices.ContainsFunc(config.Settings.Exclude, func (s string) bool { |
|
|
|
|
matches, err := regexp.MatchString(s, fp) |
|
|
|
|
if err != nil { log.Panic("invalid excludes regex", s, "error: ", err) } |
|
|
|
|
return matches |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
return is_layout || is_excluded |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func ProcessDirEntry(path string, d fs.DirEntry, meta *PageMetaData) error { |
|
|
|
|
settings := config.Settings |
|
|
|
|
var err error = nil |
|
|
|
|
@ -194,7 +207,7 @@ func ProcessDirEntry(path string, d fs.DirEntry, meta *PageMetaData) error { |
|
|
|
|
if !d.IsDir() && !SamePath(path, config.Settings.Layout) { |
|
|
|
|
source_name, ext, found := SplitPathExt(path) |
|
|
|
|
|
|
|
|
|
if found && path != settings.Layout { |
|
|
|
|
if found && !ExcludedPath(path) { |
|
|
|
|
target_path := RePrefixPath(path, settings.Target) |
|
|
|
|
|
|
|
|
|
err = MkdirPath(target_path) |
|
|
|
|
|