Added ability to put content markdown files in sub folders

Author Mitja Felicijan <m@mitjafelicijan.com> 2023-07-12 18:33:04 +0200
Committer Mitja Felicijan <m@mitjafelicijan.com> 2023-07-12 18:33:04 +0200
Commit 452d86ad1af61af7475914f3afcb5dfb2945e4c7 (patch)
-rw-r--r-- README.md 9
-rw-r--r-- main.go 17
2 files changed, 20 insertions, 6 deletions
diff --git a/README.md b/README.md
...
16
  
16
  
17
Some facts (will be more clear when you read the whole readme):
17
Some facts (will be more clear when you read the whole readme):
18
  
18
  
19
- You cannot nest your markdown file under `content` folder. All files must be
19
- You can nest your markdown file under `content` folder. You can use subfolders
20
  in the root of `content` folder.
20
  as well. Final URL will not be affected by putting markdown files in
  
21
  subfolders.
21
- `public` folder gets automatically created on `jbmafp --build`.
22
- `public` folder gets automatically created on `jbmafp --build`.
22
- All files in `static` folder will be moved to the root of `public` folder.
23
- All files in `static` folder will be moved to the root of `public` folder.
23
- When you provide `url` in your markdown files, this will create these files in
24
- When you provide `url` in your markdown files, this will create these files in
...
25
- Comes with a small embedded HTTP server you can invoke with `jbmafo --server`
26
- Comes with a small embedded HTTP server you can invoke with `jbmafo --server`
26
  which will server contents from `public` folder. Good for testing stuff.
27
  which will server contents from `public` folder. Good for testing stuff.
27
- After you have made your site you can easily create new content with `jbmafp
28
- After you have made your site you can easily create new content with `jbmafp
28
  --new "My new shitty title"`. This will create a new markdown file in content
29
  --new "My new shitty title"`. This will create a new markdown file in
29
  folder.
30
  `content` folder.
30
  
31
  
31
## Install
32
## Install
32
  
33
  
...
diff --git a/main.go b/main.go
...
144
	}
144
	}
145
  
145
  
146
	// Gets the list of all markdown files.
146
	// Gets the list of all markdown files.
147
	files, err := filepath.Glob(path.Join(projectRoot, "content/*.md"))
147
	var files []string
  
148
	err = filepath.Walk(path.Join(projectRoot, "content/"), func(path string, info os.FileInfo, err error) error {
  
149
		if err != nil {
  
150
			return err
  
151
		}
  
152
  
  
153
		if !info.IsDir() && strings.ToLower(filepath.Ext(path)) == ".md" {
  
154
			files = append(files, path)
  
155
		}
  
156
  
  
157
		return nil
  
158
	})
  
159
  
148
	if err != nil {
160
	if err != nil {
149
		panic(err)
161
		fmt.Printf("No markdown files found with error `%s`.\n", err)
  
162
		os.Exit(1)
150
	}
163
	}
151
  
164
  
152
	md := goldmark.New(
165
	md := goldmark.New(
...