69c8e807a15be7819ca69f8f0b20b23c45294dc5

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

fix(ui): display readme from .soft-serve repo

Diff

 1diff --git a/ui/pages/selection/selection.go b/ui/pages/selection/selection.go
 2index 4e0056edad21c674e56baf4358a3edc5c177512a..036b742227d5a030f0a6c2b90374f0b31964475e 100644
 3--- a/ui/pages/selection/selection.go
 4+++ b/ui/pages/selection/selection.go
 5@@ -16,6 +16,10 @@ import (
 6 	"github.com/charmbracelet/soft-serve/ui/components/tabs"
 7 )
 8 
 9+const (
10+	defaultNoContent = "No readme found.\n\nCreate a `.soft-serve` repository and add a `README.md` file to display readme."
11+)
12+
13 var (
14 	logger = log.WithPrefix("ui.selection")
15 )
16@@ -63,7 +67,8 @@ func New(c common.Common) *Selection {
17 		tabs:       t,
18 	}
19 	readme := code.New(c, "", "")
20-	readme.NoContentStyle = c.Styles.NoContent.Copy().SetString("No readme found.")
21+	readme.NoContentStyle = c.Styles.NoContent.Copy().
22+		SetString(defaultNoContent)
23 	selector := selector.New(c,
24 		[]selector.IdentifiableItem{},
25 		ItemDelegate{&c, &sel.activePane})
26@@ -198,6 +203,15 @@ func (s *Selection) Init() tea.Cmd {
27 	}
28 	sortedItems := make(Items, 0)
29 	for _, r := range repos {
30+		if r.Name() == ".soft-serve" {
31+			readme, path, err := backend.Readme(r)
32+			if err != nil {
33+				continue
34+			}
35+
36+			readmeCmd = s.readme.SetContent(readme, path)
37+		}
38+
39 		if r.IsHidden() {
40 			continue
41 		}