Documentation
¶
Overview ¶
Package amazonbooks is a gohan built-in plugin that generates Amazon book cards for article templates.
Configuration (config.yaml) ¶
plugins:
amazon_books:
enabled: true
tag: "your-associate-tag-22" # Amazon Associates tracking tag
Front-matter (article .md) ¶
books:
- asin: "4781920004"
title: "組織を変える5つの対話" # optional; used for alt text
- asin: "4873119464"
Template usage ¶
{{with index .PluginData "amazon_books"}}
{{range .Books}}
<a href="{{.LinkURL}}" target="_blank" rel="noopener">
<img src="{{.ImageURL}}" alt="{{.Title}}">
</a>
{{end}}
{{end}}
Index ¶
Constants ¶
View Source
const (
// Name is the plugin identifier, used as the key in config.yaml and PluginData.
Name = "amazon_books"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AmazonBooks ¶
type AmazonBooks struct{}
AmazonBooks implements plugin.Plugin.
func (*AmazonBooks) Enabled ¶
func (a *AmazonBooks) Enabled(cfg map[string]interface{}) bool
Enabled returns true when the plugin config has enabled: true.
func (*AmazonBooks) TemplateData ¶
func (a *AmazonBooks) TemplateData(article *model.ProcessedArticle, cfg map[string]interface{}) (map[string]interface{}, error)
TemplateData builds BookCard slice from the article's front-matter `books` key. Returns an empty map (not an error) when the article has no books.
Click to show internal directories.
Click to hide internal directories.