From b11b05bd3f48ac72a5bd897428b9ae1bb9247a23 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Mon, 3 Apr 2023 13:07:19 -0400 Subject: [PATCH] fix(ui): display readme from .soft-serve repo --- ui/pages/selection/selection.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ui/pages/selection/selection.go b/ui/pages/selection/selection.go index 4e0056edad21c674e56baf4358a3edc5c177512a..036b742227d5a030f0a6c2b90374f0b31964475e 100644 --- a/ui/pages/selection/selection.go +++ b/ui/pages/selection/selection.go @@ -16,6 +16,10 @@ import ( "github.com/charmbracelet/soft-serve/ui/components/tabs" ) +const ( + defaultNoContent = "No readme found.\n\nCreate a `.soft-serve` repository and add a `README.md` file to display readme." +) + var ( logger = log.WithPrefix("ui.selection") ) @@ -63,7 +67,8 @@ func New(c common.Common) *Selection { tabs: t, } readme := code.New(c, "", "") - readme.NoContentStyle = c.Styles.NoContent.Copy().SetString("No readme found.") + readme.NoContentStyle = c.Styles.NoContent.Copy(). + SetString(defaultNoContent) selector := selector.New(c, []selector.IdentifiableItem{}, ItemDelegate{&c, &sel.activePane}) @@ -198,6 +203,15 @@ func (s *Selection) Init() tea.Cmd { } sortedItems := make(Items, 0) for _, r := range repos { + if r.Name() == ".soft-serve" { + readme, path, err := backend.Readme(r) + if err != nil { + continue + } + + readmeCmd = s.readme.SetContent(readme, path) + } + if r.IsHidden() { continue }