opengraph

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	Title       Property   `validate:"required"`
	ObjectType  ObjectType `validate:"required"`
	URL         Property   `validate:"required"`
	Image       Property   `validate:"required"`
	Description Property
}

Metadata represents the default opengraph metadata properties used by the app on pages.

func NewMetadata

func NewMetadata(options ...Option) *Metadata

NewMetadata creates a new opengraph Metadata object with properties set to values given by the options. Where a property is not set by an option, a default value will be used.

func (*Metadata) Render

func (m *Metadata) Render() templ.Component

type ObjectType added in v0.49.0

type ObjectType struct {
	Value      string
	Attributes map[string]string
}

type Option

type Option func(*Metadata)

func WithDescription

func WithDescription(desc string) Option

WithDescription option sets a custom og:desc property with optional element attributes. If this option is not used a default description will be set.

func WithImage

func WithImage(image string) Option

WithImage option sets a custom og:image property with optional element attributes. If this option is not used a default image will be set.

func WithTitle

func WithTitle(title string) Option

WithTitle option sets a custom og:title property with optional element attributes. If this option is not used a default title will be set.

func WithType

func WithType(objectType string, attributes map[string]string) Option

WithType option sets a custom og:type property with optional element attributes. If this option is not used a default type will be set.

func WithURL

func WithURL(url string) Option

WithURL option sets a custom og:url property with optional element attributes. If this option is not used a default url will be set.

type Property

type Property struct {
	Value string
}

Jump to

Keyboard shortcuts

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