package atlas import ( "encoding/json" "fmt" ) // IssueNodes parses a Gitea `/repos/issues/search` response (the // authenticated user's own open issues, newest first) into one node per // issue, linking out to the issue. func IssueNodes(searchJSON []byte) ([]Node, error) { var issues []struct { Number int `json:"number"` Title string `json:"title"` HTMLURL string `json:"html_url"` Repository struct { FullName string `json:"full_name"` } `json:"repository"` } if err := json.Unmarshal(searchJSON, &issues); err != nil { return nil, fmt.Errorf("parse issues: %w", err) } nodes := make([]Node, 0, len(issues)) for _, i := range issues { nodes = append(nodes, Node{ Title: fmt.Sprintf("#%d %s", i.Number, i.Title), Tags: []string{"live ยท Gitea", i.Repository.FullName}, URL: i.HTMLURL, }) } return nodes, nil }