amazonbooks

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 3 Imported by: 0

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 New

func New() *AmazonBooks

New returns a new AmazonBooks plugin instance.

func (*AmazonBooks) Enabled

func (a *AmazonBooks) Enabled(cfg map[string]interface{}) bool

Enabled returns true when the plugin config has enabled: true.

func (*AmazonBooks) Name

func (a *AmazonBooks) Name() string

Name returns the plugin identifier.

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.

type BookCard

type BookCard struct {
	ASIN     string
	Title    string
	ImageURL string
	LinkURL  string
}

BookCard is the data exposed to templates for a single book.

Jump to

Keyboard shortcuts

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