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