diff options
| -rw-r--r-- | entry.go | 17 | ||||
| -rw-r--r-- | utils.go | 7 | 
2 files changed, 16 insertions, 8 deletions
| @@ -24,19 +24,20 @@ type logEntry struct {  }  func findEntries(cfg config) (entries []Renderer, err error) { -	baseEntryRegex := regexp.MustCompile(".*\\.md") -	logEntryRegex := regexp.MustCompile("(20[0-9]{2})-([0-9]{2})-([0-9]{2}).*\\.md") +	baseEntryRegex := regexp.MustCompile("([A-z\\-]+)\\.md") +	logEntryRegex := regexp.MustCompile("(20[0-9]{2})-([0-9]{2})-([0-9]{2})-([A-z\\-]+)\\.md")  	err = filepath.Walk(cfg.DocsRoot, func(p string, f os.FileInfo, e error) error {  		if !f.IsDir() && baseEntryRegex.MatchString(f.Name()) { -			fmt.Println(p) -			newBaseEntry := entry{name: f.Name(), fullPath: p} +                        baseCaptures := baseEntryRegex.FindStringSubmatch(f.Name()) +			newBaseEntry := entry{name: nameify(baseCaptures[1]), fullPath: p} +			fmt.Println(newBaseEntry.name)  			if logEntryRegex.MatchString(f.Name()) { -				captures := logEntryRegex.FindStringSubmatch(f.Name()) -				y, _ := strconv.Atoi(captures[1]) -				m, _ := strconv.Atoi(captures[2]) -				d, _ := strconv.Atoi(captures[3]) +				logCaptures := logEntryRegex.FindStringSubmatch(f.Name()) +				y, _ := strconv.Atoi(logCaptures[1]) +				m, _ := strconv.Atoi(logCaptures[2]) +				d, _ := strconv.Atoi(logCaptures[3])  				newLogEntry := logEntry{  					baseEntry: newBaseEntry, @@ -18,3 +18,10 @@ func readConfig(file string) (cfg config, err error) {  	cfg.BaseUrl = strings.TrimSuffix(cfg.BaseUrl, "/")  	return  } + +func nameify(raw string) (clean string) { +    clean = strings.ReplaceAll(raw, "-", " ") +    clean = strings.TrimSpace(clean) +    clean = strings.Title(clean) +    return +} | 
