package components import ( "fmt" "reichard.io/antholume/database" "reichard.io/antholume/ngtemplates/common" ) func FirstNonZero[T comparable](all ...T) T { var zeroT T for _, item := range all { if item != zeroT { return item } } return zeroT } func orUnknown(val *string) string { if val == nil { return "Unknown" } return *val } templ DocumentCard(document database.GetDocumentsWithStatsRow) {

Title

{ orUnknown(document.Title) }

Author

{ orUnknown(document.Author) }

Progress

{ fmt.Sprintf("%.2f%%", document.Percentage) }

Time Read

{ common.NiceSeconds(document.TotalTimeSeconds) }

@ActivitySVG("") if document.Filepath != nil && *document.Filepath != "" { @DownloadSVG("") } else { @DownloadSVG("text-gray-200 dark:text-gray-600") }
}