talc/pkg/tal/book.go
2020-03-17 16:36:19 +01:00

36 lines
503 B
Go

package tal
import "fmt"
type Book struct {
Path string
Base string
Meta map[string]string
}
func (b *Book) String() string {
title := b.Meta["SORTtitle"]
if title == "" {
title = b.Meta["title"]
}
author := b.Meta["SORTauthors"]
if author == "" {
author = b.Meta["author"]
}
if title != "" && author != "" {
return fmt.Sprintf("%s - %s", author, title)
}
if title == "" && author != "" {
return author
}
if title != "" && author == "" {
return title
}
return b.Base
}