bookshelf

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 6 Imported by: 0

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"
    title: "組織を変える5つの対話"   # optional; used for alt text

Template usage (bookshelf.html)

{{range index .VirtualPageData "books"}}
  <a href="{{.LinkURL}}" target="_blank" rel="noopener">
    <img src="{{.ImageURL}}" alt="{{.Title}}">
  </a>
  {{if .ArticleURL}}<a href="{{.ArticleURL}}">{{.ArticleTitle}}</a>{{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
}

BookEntry is the data exposed to templates for a single book on the bookshelf.

type Bookshelf

type Bookshelf struct{}

Bookshelf implements SitePlugin.

func New

func New() *Bookshelf

New returns a new Bookshelf plugin instance.

func (*Bookshelf) Enabled

func (b *Bookshelf) Enabled(cfg map[string]interface{}) bool

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

func (*Bookshelf) Name

func (b *Bookshelf) Name() string

Name returns the plugin identifier.

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.

Jump to

Keyboard shortcuts

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