From 452d86ad1af61af7475914f3afcb5dfb2945e4c7 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Wed, 12 Jul 2023 18:33:04 +0200 Subject: Added ability to put content markdown files in sub folders --- main.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 71f5f94..fecc2d8 100644 --- a/main.go +++ b/main.go @@ -144,9 +144,22 @@ func buildProject(projectRoot string) { } // Gets the list of all markdown files. - files, err := filepath.Glob(path.Join(projectRoot, "content/*.md")) + var files []string + err = filepath.Walk(path.Join(projectRoot, "content/"), func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + + if !info.IsDir() && strings.ToLower(filepath.Ext(path)) == ".md" { + files = append(files, path) + } + + return nil + }) + if err != nil { - panic(err) + fmt.Printf("No markdown files found with error `%s`.\n", err) + os.Exit(1) } md := goldmark.New( -- cgit v1.2.3