package atlas import ( "encoding/json" "fmt" ) // RepoNodes parses a Gitea `/user/repos` response (the token owner's own // repositories) into one node per repo, linking out to the repo. Archived // repos are dropped: the atlas shows where work happens, and an archived repo // is by definition somewhere it does not. func RepoNodes(listJSON []byte) ([]Node, error) { var repos []struct { Name string `json:"name"` Description string `json:"description"` HTMLURL string `json:"html_url"` Archived bool `json:"archived"` Language string `json:"language"` } if err := json.Unmarshal(listJSON, &repos); err != nil { return nil, fmt.Errorf("parse repos: %w", err) } nodes := make([]Node, 0, len(repos)) for _, r := range repos { if r.Archived { continue } tags := []string{"live ยท Gitea"} if r.Language != "" { tags = append(tags, r.Language) } nodes = append(nodes, Node{ Title: r.Name, Desc: r.Description, Tags: tags, URL: r.HTMLURL, }) } return nodes, nil }