package lazyseo

import "golazy.dev/lazyseo"

Package lazyseo renders common document metadata for GoLazy views.

lazyapp installs the standard SEO helpers when a renderer is configured, and lazycontroller.Base exposes convenience methods for setting page metadata from controller actions. Use those integrations in normal applications.

The package can also be used directly with any value that supports Set(string, any), which keeps metadata rendering independent from controller internals and from a specific template engine.

Variables

var (
	WebPage		= PageKind{OpenGraph: "website", Schema: "WebPage"}
	WebSite		= PageKind{OpenGraph: "website", Schema: "WebSite"}
	Article		= PageKind{OpenGraph: "article", Schema: "Article"}
	BlogPosting	= PageKind{OpenGraph: "article", Schema: "BlogPosting"}
	NewsArticle	= PageKind{OpenGraph: "article", Schema: "NewsArticle"}
	Product		= PageKind{OpenGraph: "product", Schema: "Product"}
	Profile		= PageKind{OpenGraph: "profile", Schema: "ProfilePage"}
	Book		= PageKind{OpenGraph: "book", Schema: "Book"}
	Video		= PageKind{OpenGraph: "video.other", Schema: "VideoObject"}
	MusicSong	= PageKind{OpenGraph: "music.song", Schema: "MusicRecording"}
	MusicAlbum	= PageKind{OpenGraph: "music.album", Schema: "MusicAlbum"}
	Place		= PageKind{OpenGraph: "place", Schema: "Place"}
	Restaurant	= PageKind{OpenGraph: "place", Schema: "Restaurant"}
	Organization	= PageKind{OpenGraph: "website", Schema: "Organization"}
)

Functions

func DefaultJSONLD

DefaultJSONLD builds a conventional schema.org value from metadata.

func DefaultJSONLD(meta Meta) any

func Helpers

Helpers returns the template helpers provided by lazyseo.

func Helpers(defaults ...Option) map[string]any

Types

type Alternate

Alternate describes an alternate URL for the current page.

type Alternate struct {
	Language	string
	URL		string
	Media		string
	Type		string
	Title		string
}

type Meta

Meta contains the metadata emitted by the seo view helper.

type Meta struct {
	Title		string
	SiteName	string
	Description	string
	Author		string
	Language	string
	URL		string
	Canonical	string
	Alternates	[]Alternate
	Image		string
	ImageAlt	string
	OpenGraph	OpenGraph
	Type		string
	SchemaType	string
	Locale		string
	Twitter		TwitterCard
	TwitterType	string
	JSONLD		[]any
	PublishedTime	time.Time
	UpdatedTime	time.Time
}
func New

New builds Meta with the supplied options.

func New(options ...Option) *Meta
func Set

Set stores request-local SEO metadata on a controller.

func Set(controller setter, options ...Option) *Meta

type OpenGraph

OpenGraph overrides metadata emitted for Open Graph tags.

type OpenGraph struct {
	Title		string
	Description	string
	URL		string
	Image		string
	ImageAlt	string
	ImageWidth	int
	ImageHeight	int
	Type		string
	SiteName	string
	Locale		string
}

type Option

Option configures Meta values.

type Option func(*Meta)
func AlternateURL
func AlternateURL(language, url string) Option
func Author
func Author(value string) Option
func Canonical
func Canonical(value string) Option
func Description
func Description(value string) Option
func Image
func Image(value string) Option
func ImageAlt
func ImageAlt(value string) Option
func JSONLD
func JSONLD(value any) Option
func Kind
func Kind(kind PageKind) Option
func Language
func Language(value string) Option
func LastUpdated
func LastUpdated(value time.Time) Option
func Locale
func Locale(value string) Option
func OpenGraphData
func OpenGraphData(value OpenGraph) Option
func OpenGraphType
func OpenGraphType(value string) Option
func PublishedTime
func PublishedTime(value time.Time) Option
func SchemaType
func SchemaType(value string) Option
func SiteName
func SiteName(value string) Option
func Title
func Title(value string) Option
func TwitterCardData
func TwitterCardData(value TwitterCard) Option
func TwitterCardType
func TwitterCardType(value string) Option
func Type
func Type(value string) Option
func URL
func URL(value string) Option
func UpdatedTime
func UpdatedTime(value time.Time) Option

type PageKind

PageKind is a common page/content kind that maps to Open Graph and JSON-LD.

type PageKind struct {
	OpenGraph	string
	Schema		string
}

type TwitterCard

TwitterCard overrides metadata emitted for Twitter card tags.

type TwitterCard struct {
	Card		string
	Title		string
	Description	string
	Image		string
	ImageAlt	string
	Site		string
	Creator		string
}

Directories

Path Synopsis
lazyseo/jsonld Package jsonld provides small schema.org JSON-LD value types for lazyseo.