diff options
Diffstat (limited to 'handler.go')
| -rw-r--r-- | handler.go | 18 | 
1 files changed, 2 insertions, 16 deletions
| @@ -1,14 +1,12 @@  package main  import ( -	"bufio"  	"os"  	"fmt"  	"io/ioutil"  	"net/http"  	"path/filepath"  	"regexp" -	"strings"  	"strconv"  ) @@ -23,18 +21,6 @@ type Recipe struct {  	Html	string  } -func titleFromMd(md string) string { -	scanner := bufio.NewScanner(strings.NewReader(md)) -	for scanner.Scan() { -		line := scanner.Text() -		cut, found := strings.CutPrefix(line, "# ") -		if (found) { -			return cut -		} -	} -	return "no title detected" -} -  func indexGet(w http.ResponseWriter, r *http.Request) {  	entries, err := os.ReadDir("data/storage/recipes") @@ -60,7 +46,7 @@ func indexGet(w http.ResponseWriter, r *http.Request) {  		recipes = append(recipes, Recipe{  			v.Name(), -			titleFromMd(string(data)), +			titleFromMarkup(string(data)),  			string(data),  			"",  		}) @@ -84,7 +70,7 @@ func recipeGet(w http.ResponseWriter, r *http.Request) {  	recipe := Recipe{  		idStr, -		titleFromMd(string(data)), +		titleFromMarkup(string(data)),  		string(data),  		"",  	} | 
