utils

package
v0.0.0-...-5c6ceab Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorStyle     = lipgloss.NewStyle().Foreground(lipgloss.Color("#FF8080"))
	SuccessStyle   = lipgloss.NewStyle().Foreground(lipgloss.Color("#80FF80"))
	InfoStyle      = lipgloss.NewStyle().Foreground(lipgloss.Color("#8080FF"))
	RowStyle       = lipgloss.NewStyle().Padding(0, 1)
	UsernameStyle  = RowStyle.Copy().Foreground(lipgloss.Color("244"))
	LabelColStyle  = RowStyle.Copy().Foreground(lipgloss.Color("99"))
	ActiveTabStyle = RowStyle.Copy().
					Background(lipgloss.Color("99")).
					Foreground(lipgloss.Color("#fff")).
					Margin(1, 0, 0, 2)
	InactiveTabStyle = RowStyle.Copy().Margin(1, 0, 0, 2).Background(lipgloss.Color("#353533"))
	TitleStyle       = func() lipgloss.Style {
		b := lipgloss.RoundedBorder()

		b.Right = "├"
		return RowStyle.Copy().BorderStyle(b).Foreground(lipgloss.Color("99"))
	}()
	AuthorStyle = lipgloss.NewStyle().
				Background(lipgloss.Color("99")).
				Foreground(lipgloss.Color("#fff")).
				Padding(0, 1).
				MarginLeft(2)

	ErrorCodes = map[string]string{
		"GRAPHQL_VALIDATION_FAILED": "GraphQL query is invalid.",
		"UNAUTHENTICATED":           "No token set. Please run 'hashnode auth <token>' to set a token.",
		"FORBIDDEN":                 "Not allowed to access this resource.",
		"BAD_USER_INPUT":            "User input is invalid.",
		"NOT_FOUND":                 "Resource not found.",
	}
)

Functions

func CheckToken

func CheckToken()

func Exit

func Exit(message ...interface{})

func FindIndex

func FindIndex(list []string, item string) int

func FormatDate

func FormatDate(date string) string

func Linkify

func Linkify(text, href string) string

func Listify

func Listify[T any](list []T) string

func OpenBrowser

func OpenBrowser(url string) error

func RenderAPIErrors

func RenderAPIErrors(errors []Error)

func RenderStatusBar

func RenderStatusBar(width int, author string, readTime int, published string, scrollPercent float64) string

func RenderSuccess

func RenderSuccess(message string)

func RenderTitle

func RenderTitle(title string, width int) string

func SetToken

func SetToken(token string, isSearchToken bool)

func SetupConfig

func SetupConfig()

Types

type Error

type Error struct {
	Message    string   `json:"message"`
	Path       []string `json:"path"`
	Extensions struct {
		Code string `json:"code"`
	} `json:"extensions"`
}

type Post

type Post struct {
	Id          string `json:"id"`
	Title       string `json:"title"`
	Brief       string `json:"brief"`
	PublishedAt string `json:"publishedAt"`
	Author      struct {
		Name string `json:"name"`
	} `json:"author"`
	URL               string `json:"url"`
	ReadTimeInMinutes int    `json:"readTimeInMinutes"`
	Content           struct {
		Markdown string `json:"markdown"`
	} `json:"content"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL