Skip to content

Commit e4042ea

Browse files
committed
Ensure that event content path exists
Fixes #90 Signed-off-by: Matt Stratton <[email protected]>
1 parent 8498b46 commit e4042ea

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

create/speaker.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ func NewSpeaker(speaker model.Speaker, city string, year string) (err error) {
202202
return
203203
}
204204

205+
if err := os.MkdirAll(filepath.Join(helpers.EventContentPath(city, year), "speakers"), 0777); err != nil {
206+
log.Fatal(err)
207+
}
205208
s := []string{strings.TrimSpace(cleanName), ".md"}
206209
f, err := os.Create(filepath.Join(helpers.EventContentPath(city, year), "speakers", strings.Join(s, "")))
207210
if err != nil {

helpers/event_content_path.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
package helpers
22

33
import (
4+
"log"
5+
"os"
46
"path/filepath"
57
"strings"
68
)
79

810
// EventContentPath returns the path for content for an event based upon city and year
911
func EventContentPath(city, year string) (eventContentPath string) {
1012
s := []string{strings.TrimSpace(year), "-", strings.Replace(strings.TrimSpace(strings.ToLower(city)), " ", "-", 10)}
13+
if err := os.MkdirAll(filepath.Join(GetWebdir(), "content", "events", strings.Join(s, "")), 0777); err != nil {
14+
log.Fatal(err)
15+
}
1116
return filepath.Join(GetWebdir(), "content", "events", strings.Join(s, ""))
1217
}

0 commit comments

Comments
 (0)