socialcards

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg map[string]any) *plugin.Plugin

New constructs the social_cards plugin from its config map.

Types

type CardParams

type CardParams struct {
	Title          string
	Description    string
	SiteTitle      string
	CollectionName string
	Date           time.Time
	// DateExplicit gates the footer date: an inferred (mtime) date is build
	// metadata, not a publish date, and is never shown.
	DateExplicit bool
	BgColor      color.NRGBA
	AccentColor  color.NRGBA
	// AccentColor2 turns the accent strip into a two-stop horizontal
	// gradient when non-nil.
	AccentColor2 *color.NRGBA
	TextColor    color.NRGBA
	// LogoImage is the brand mark drawn top-left, already resized to
	// logoDrawSize. Nil draws no logo.
	LogoImage *image.NRGBA
	// WatermarkImage is the large low-opacity mark bleeding off the right
	// edge, already resized to watermarkLongEdge. Nil draws no watermark.
	WatermarkImage   *image.NRGBA
	WatermarkOpacity float64
	// BgImage is an optional background image, already fitted to the card
	// (cover crops to exactly 1200x630, contain letterboxes inside it). It is
	// drawn centered over the gradient and under the watermark and all text.
	BgImage *image.NRGBA
	// BgImageOpacity dims the background image so text stays readable over
	// busy artwork. Zero or negative means fully opaque.
	BgImageOpacity float64
	// GradientOverride replaces the auto-derived background gradient: nil
	// keeps the automatic contrast gradient, one color fills solid, two
	// colors blend vertically from the first (top) to the second (bottom).
	GradientOverride []color.NRGBA
	Faces            *FaceSet
	BoldFont         *opentype.Font
}

CardParams holds all data needed to render a single social card.

type FaceSet

type FaceSet struct {
	Small  font.Face // 20pt site title, next to a logo mark
	Brand  font.Face // 28pt bold site title, standing alone (no logo)
	Desc   font.Face // 32pt description
	Bold   font.Face // 76pt title, first ladder rung (may be resized per-card)
	Footer font.Face // 20pt footer
}

FaceSet holds pre-created font faces for a single goroutine. Sizes follow OG-image readability guidance: cards render at roughly 40% scale in feeds and 200px wide as thumbnails, so nothing important goes below ~20px.

Jump to

Keyboard shortcuts

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