Documentation
¶
Overview ¶
Package bookshelf is a gohan built-in SitePlugin that generates a bookshelf page by aggregating book entries from every article's front-matter.
Configuration (config.yaml) ¶
plugins:
bookshelf:
enabled: true
tag: "your-associate-tag-22" # Amazon Associates tracking tag
Front-matter (article .md) — same key used by amazon_books plugin ¶
books:
- asin: "4781920004" # Amazon ASIN — generates image + Amazon link
title: "組織を変える5つの対話" # optional; used for alt text
- url: "https://booth.pm/..." # non-Amazon: direct sales URL (no cover image)
title: "同人誌タイトル"
Template usage (bookshelf.html) ¶
{{range index .VirtualPageData "categories"}}
<h2>{{if .Name}}{{.Name}}{{else}}Uncategorized{{end}}</h2>
{{range .Books}}
<a href="{{.LinkURL}}" target="_blank" rel="noopener">
<img src="{{.ImageURL}}" alt="{{.Title}}">
</a>
{{if .ArticleURL}}<a href="{{.ArticleURL}}">{{.ArticleTitle}}</a>{{end}}
{{end}}
{{end}}
Index ¶
Constants ¶
View Source
const (
// Name is the plugin identifier used as the key in config.yaml and registry.
Name = "bookshelf"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BookEntry ¶
type BookEntry struct {
ASIN string
Title string
ImageURL string
LinkURL string
ArticleSlug string
ArticleTitle string
ArticleURL string
Date time.Time
Categories []string
}
BookEntry is the data exposed to templates for a single book on the bookshelf.
type Bookshelf ¶
type Bookshelf struct{}
Bookshelf implements SitePlugin.
func (*Bookshelf) VirtualPages ¶
func (b *Bookshelf) VirtualPages(site *model.Site, cfg map[string]interface{}) ([]*model.VirtualPage, error)
VirtualPages collects all book entries from article front-matter and returns one VirtualPage per locale containing the aggregated bookshelf data. Each page's Data map contains:
"books" []BookEntry — all entries sorted by date descending "categories" []CategoryGroup — entries grouped by article category, sorted alphabetically
type CategoryGroup ¶ added in v1.0.14
CategoryGroup groups BookEntries under a single category name. When Name is empty the books have no category assigned.
Click to show internal directories.
Click to hide internal directories.