meta.go (624B)
1 package article 2 3 import ( 4 "fmt" 5 6 "git.figbert.com/caret/ui" 7 8 "github.com/charmbracelet/lipgloss" 9 ) 10 11 func getReaderModeMetaBlock(title string, url string) string { 12 lineWidth := 72 13 14 style := lipgloss.NewStyle(). 15 BorderStyle(lipgloss.RoundedBorder()). 16 PaddingLeft(1). 17 PaddingRight(1). 18 MarginLeft(1). 19 MarginTop(1). 20 MarginBottom(1). 21 Width(lineWidth) 22 23 urlRunes := []rune(url) 24 if len(urlRunes) > lineWidth-2 { 25 url = string(append(urlRunes[:lineWidth-3], '…')) 26 } 27 28 return style.Render( 29 fmt.Sprintf( 30 "%s\n%s\n%s", 31 title, ui.LobstersRed().Render(url), 32 ui.Orange().Render("Reader Mode"), 33 ), 34 ) 35 }