add URL to Page struct

This commit is contained in:
ed 2020-01-04 16:31:46 +01:00
parent dd3b4159ec
commit 06b03d7480
1 changed files with 9 additions and 5 deletions

14
main.go
View File

@ -15,6 +15,7 @@ type hlink struct {
type Page struct { type Page struct {
Body string Body string
Links []hlink Links []hlink
URL string
} }
type Game struct { type Game struct {
@ -80,15 +81,18 @@ func fparse(fname string) Game{
case len(line) == 0: case len(line) == 0:
pcount++ pcount++
case string(line[0]) == ":": case string(line[0]) == ":":
game.Pages = append(game.Pages, Page{Body:cutFirstWord(line)}) sline := strings.Split(line, " ")
fmt.Println(cutFirstWord(line)) url := sline[0][1:] + ".html"
fmt.Println(url)
body := strings.Join(sline[1:]," ")
fmt.Println(body)
game.Pages = append(game.Pages, Page{Body:body,
URL: url})
//game.Pages = append(game.Pages, Page{Body:cutFirstWord(line)})
case string(line[0]) == "-": case string(line[0]) == "-":
newLink := line2link(line) newLink := line2link(line)
game.Pages[pcount].Links = append(game.Pages[pcount].Links, newLink) game.Pages[pcount].Links = append(game.Pages[pcount].Links, newLink)
} }
//fmt.Println(firstchar)
//game.Pages = append(game.Pages()
} }
return game return game
} }