Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Article ¶
type Article struct { OpenGraphObject PublishedTime string // article:published_time, the time the article was first published ModifiedTime string // article:modified_time, the time the article was last modified ExpirationTime string // article:expiration_time, the time the article will expire Author []string // article:author, URLs to the authors of the article Section string // article:section, a high-level section name Tag []string // article:tag, tags of the article }
Article represents the Open Graph article metadata. For more details about the meaning of the properties see: https://ogp.me/#type_article
Example usage:
Pure struct usage:
// Create an article using pure struct article := &opengraph.Article{ OpenGraphObject: opengraph.OpenGraphObject{ Title: "Example Article Title", URL: "https://www.example.com/articles/example-article", Description: "This is an example article description.", Image: "https://www.example.com/images/article.jpg", }, PublishedTime: "2024-09-15T09:00:00Z", ModifiedTime: "2024-09-15T10:00:00Z", ExpirationTime: "2024-12-31T23:59:59Z", Author: []string{"https://www.example.com/authors/jane-doe"}, Section: "Technology", Tag: []string{"tech", "innovation", "example"}, }
Factory method usage:
// Create an article article := opengraph.NewArticle( "Example Article Title", "https://www.example.com/articles/example-article", "This is an example article description.", "https://www.example.com/images/article.jpg", "2024-09-15T09:00:00Z", "2024-09-15T10:00:00Z", "2024-12-31T23:59:59Z", []string{"https://www.example.com/authors/jane-doe"}, "Technology", []string{"tech", "innovation", "example"}, )
// Rendering the HTML meta tags using templ:
templ Page() { @article.ToMetaTgs() }
// Rendering the HTML meta tags as `template.HTML` value:
metaTagsHtml := article.ToGoHTMLMetaTgs()
Expected output:
<meta property="og:type" content="article"/> <meta property="og:title" content="Example Article Title"/> <meta property="og:url" content="https://www.example.com/articles/example-article"/> <meta property="og:description" content="This is an example article description."/> <meta property="og:image" content="https://www.example.com/images/article.jpg"/> <meta property="article:published_time" content="2024-09-15T09:00:00Z"/> <meta property="article:modified_time" content="2024-09-15T10:00:00Z"/> <meta property="article:expiration_time" content="2024-12-31T23:59:59Z"/> <meta property="article:section" content="Technology"/> <meta property="article:author" content="https://www.example.com/authors/jane-doe"/> <meta property="article:tag" content="tech"/> <meta property="article:tag" content="innovation"/> <meta property="article:tag" content="example"/>
func NewArticle ¶
func NewArticle(title, url, description, image, publishedTime, modifiedTime, expirationTime string, author []string, section string, tags []string) *Article
NewArticle initializes an Article with the default type "article".
func (*Article) ToGoHTMLMetaTags ¶
ToGoHTMLMetaTags generates the HTML meta tags for the Open Graph Audio as `template.HTML` value for Go's `html/template`.
func (*Article) ToMetaTags ¶
ToMetaTags generates the HTML meta tags for the Open Graph Article using templ.Component.
type Audio ¶
type Audio struct { OpenGraphObject Duration string // music:duration, duration of the audio in seconds ArtistURL string // music:musician, URL to the musician or artist }
Audio represents the Open Graph audio metadata. For more details about the meaning of the properties see: https://ogp.me/#metadata
Example usage:
Pure struct usage:
// Create an audio object using pure struct audio := &opengraph.Audio{ OpenGraphObject: opengraph.OpenGraphObject{ Title: "Example Audio Title", URL: "https://www.example.com/audio/example-audio", Description: "This is an example audio description.", Image: "https://www.example.com/images/audio.jpg", }, Duration: "300", // Duration in seconds ArtistURL: "https://www.example.com/musicians/jane-doe", }
Factory method usage:
// Create an audio object using the factory method audio := opengraph.NewAudio( "Example Audio Title", "https://www.example.com/audio/example-audio", "This is an example audio description.", "https://www.example.com/images/audio.jpg", "300", // Duration in seconds "https://www.example.com/musicians/jane-doe", )
// Rendering the HTML meta tags using templ:
templ Page() { @audio.ToMetaTgs() }
// Rendering the HTML meta tags as `template.HTML` value:
metaTagsHtml := audio.ToGoHTMLMetaTgs()
Expected output:
<meta property="og:type" content="music.audio"/> <meta property="og:title" content="Example Audio Title"/> <meta property="og:url" content="https://www.example.com/audio/example-audio"/> <meta property="og:description" content="This is an example audio description."/> <meta property="og:image" content="https://www.example.com/images/audio.jpg"/> <meta property="music:duration" content="300"/> <meta property="music:musician" content="https://www.example.com/musicians/jane-doe"/>
func (*Audio) ToGoHTMLMetaTags ¶
ToGoHTMLMetaTags generates the HTML meta tags for the Open Graph Audio as `template.HTML` value for Go's `html/template`.
func (*Audio) ToMetaTags ¶
ToMetaTags generates the HTML meta tags for the Open Graph Audio as templ.Component.
type Book ¶
type Book struct { OpenGraphObject Author []string // book:author, URLs to the authors of the book ISBN string // book:isbn, ISBN number of the book ReleaseDate string // book:release_date, the release date of the book Tag []string // book:tag, tags for the book }
Book represents the Open Graph book metadata. For more details about the meaning of the properties see: https://ogp.me/#type_book
Example usage:
Pure struct usage:
// Create a book using pure struct book := &opengraph.Book{ OpenGraphObject: opengraph.OpenGraphObject{ Title: "Example Book Title", URL: "https://www.example.com/books/example-book", Description: "This is an example book description.", Image: "https://www.example.com/images/book.jpg", }, ISBN: "978-3-16-148410-0", ReleaseDate: "2024-09-15", Author: []string{"https://www.example.com/authors/jane-doe"}, Tag: []string{"fiction", "bestseller", "example"}, }
Factory method usage:
// Create a book book := opengraph.NewBook( "Example Book Title", "https://www.example.com/books/example-book", "This is an example book description.", "https://www.example.com/images/book.jpg", "978-3-16-148410-0", "2024-09-15", []string{"https://www.example.com/authors/jane-doe"}, []string{"fiction", "bestseller", "example"}, )
// Rendering the HTML meta tags using templ:
templ Page() { @book.ToMetaTgs() }
// Rendering the HTML meta tags as `template.HTML` value:
metaTagsHtml := book.ToGoHTMLMetaTgs()
Expected output:
<meta property="og:type" content="book"/> <meta property="og:title" content="Example Book Title"/> <meta property="og:url" content="https://www.example.com/books/example-book"/> <meta property="og:description" content="This is an example book description."/> <meta property="og:image" content="https://www.example.com/images/book.jpg"/> <meta property="book:isbn" content="978-3-16-148410-0"/> <meta property="book:release_date" content="2024-09-15"/> <meta property="book:author" content="https://www.example.com/authors/jane-doe"/> <meta property="book:tag" content="fiction"/> <meta property="book:tag" content="bestseller"/> <meta property="book:tag" content="example"/>
func (*Book) ToGoHTMLMetaTags ¶
ToGoHTMLMetaTags generates the HTML meta tags for the Open Graph Book as `template.HTML` value for Go's `html/template`.
func (*Book) ToMetaTags ¶
ToMetaTags generates the HTML meta tags for the Open Graph Book as templ.Component.
type Business ¶
type Business struct { OpenGraphObject StreetAddress string // business:contact_data:street_address, street address of the business Locality string // business:contact_data:locality, locality or city of the business Region string // business:contact_data:region, region or state of the business PostalCode string // business:contact_data:postal_code, postal code of the business Country string // business:contact_data:country_name, country of the business Email string // business:contact_data:email, email address of the business PhoneNumber string // business:contact_data:phone_number, phone number of the business Website string // business:contact_data:website, website URL of the business }
Business represents the Open Graph business metadata. For more details about the meaning of the properties see: https://ogp.me/#metadata
Example usage:
Pure struct usage:
// Create a business using pure struct business := &opengraph.Business{ OpenGraphObject: opengraph.OpenGraphObject{ Title: "Example Business", URL: "https://www.example.com/business", Description: "This is an example business description.", Image: "https://www.example.com/images/business.jpg", }, StreetAddress: "123 Main St", Locality: "Anytown", Region: "CA", PostalCode: "12345", Country: "USA", Email: "info@example.com", PhoneNumber: "+1-800-555-1234", Website: "https://www.example.com", }
Factory method usage:
// Create a business business := opengraph.NewBusiness( "Example Business", "https://www.example.com/business", "This is an example business description.", "https://www.example.com/images/business.jpg", "123 Main St", "Anytown", "CA", "12345", "USA", "info@example.com", "+1-800-555-1234", "https://www.example.com", )
// Rendering the HTML meta tags using templ:
templ Page() { @business.ToMetaTgs() }
// Rendering the HTML meta tags as `template.HTML` value:
metaTagsHtml := business.ToGoHTMLMetaTgs()
Expected output:
<meta property="og:type" content="business.business"/> <meta property="og:title" content="Example Business"/> <meta property="og:url" content="https://www.example.com/business"/> <meta property="og:description" content="This is an example business description."/> <meta property="og:image" content="https://www.example.com/images/business.jpg"/> <meta property="business:contact_data:street_address" content="123 Main St"/> <meta property="business:contact_data:locality" content="Anytown"/> <meta property="business:contact_data:region" content="CA"/> <meta property="business:contact_data:postal_code" content="12345"/> <meta property="business:contact_data:country_name" content="USA"/> <meta property="business:contact_data:email" content="info@example.com"/> <meta property="business:contact_data:phone_number" content="+1-800-555-1234"/> <meta property="business:contact_data:website" content="https://www.example.com"/>
func NewBusiness ¶
func NewBusiness(title, url, description, image, streetAddress, locality, region, postalCode, country, email, phoneNumber, website string) *Business
NewBusiness initializes a Business with the default type "business.business".
func (*Business) ToGoHTMLMetaTags ¶
ToGoHTMLMetaTags generates the HTML meta tags for the Open Graph Business as `template.HTML` value for Go's `html/template`.
func (*Business) ToMetaTags ¶
ToMetaTags generates the HTML meta tags for the Open Graph Business as templ.Component.
type Event ¶
type Event struct { OpenGraphObject StartDate string // event:start_date, the start date and time of the event EndDate string // event:end_date, the end date and time of the event Location string // event:location, the location of the event }
Event represents the Open Graph event metadata. For more details about the meaning of the properties see: https://ogp.me/#metadata
Example usage:
Pure struct usage:
// Create an event using pure struct event := &opengraph.Event{ OpenGraphObject: opengraph.OpenGraphObject{ Title: "Example Event Title", URL: "https://www.example.com/event/example-event", Description: "This is an example event description.", Image: "https://www.example.com/images/event.jpg", }, StartDate: "2024-09-15T09:00:00Z", EndDate: "2024-09-15T18:00:00Z", Location: "Anytown Convention Center", }
Factory method usage:
// Create an event using the factory method event := opengraph.NewEvent( "Example Event Title", "https://www.example.com/event/example-event", "This is an example event description.", "https://www.example.com/images/event.jpg", "2024-09-15T09:00:00Z", "2024-09-15T18:00:00Z", "Anytown Convention Center", )
// Rendering the HTML meta tags using templ:
templ Page() { @event.ToMetaTgs() }
// Rendering the HTML meta tags as `template.HTML` value:
metaTagsHtml := event.ToGoHTMLMetaTgs()
Expected output:
<meta property="og:type" content="event"/> <meta property="og:title" content="Example Event Title"/> <meta property="og:url" content="https://www.example.com/event/example-event"/> <meta property="og:description" content="This is an example event description."/> <meta property="og:image" content="https://www.example.com/images/event.jpg"/> <meta property="event:start_date" content="2024-09-15T09:00:00Z"/> <meta property="event:end_date" content="2024-09-15T18:00:00Z"/> <meta property="event:location" content="Anytown Convention Center"/>
func (*Event) ToGoHTMLMetaTags ¶
ToGoHTMLMetaTags generates the HTML meta tags for the Open Graph Event as `template.HTML` value for Go's `html/template`.
func (*Event) ToMetaTags ¶
ToMetaTags generates the HTML meta tags for the Open Graph Event as templ.Component.
type MusicAlbum ¶
type MusicAlbum struct { OpenGraphObject Musician []string // music:musician, URLs to the musicians in the album ReleaseDate string // music:release_date, the release date of the album Genre string // music:genre, genre of the album }
MusicAlbum represents the Open Graph music album metadata. For more details about the meaning of the properties see: https://ogp.me/#type_music.album
Example usage:
Pure struct usage:
// Create a music album using pure struct musicAlbum := &opengraph.MusicAlbum{ OpenGraphObject: opengraph.OpenGraphObject{ Title: "Example Album Title", URL: "https://www.example.com/music/album/example-album", Description: "This is an example album description.", Image: "https://www.example.com/images/album.jpg", }, Musician: []string{"https://www.example.com/musicians/jane-doe", "https://www.example.com/musicians/john-doe"}, ReleaseDate: "2024-09-15", Genre: "Rock", }
Factory method usage:
// Create a music album musicAlbum := opengraph.NewMusicAlbum( "Example Album Title", "https://www.example.com/music/album/example-album", "This is an example album description.", "https://www.example.com/images/album.jpg", "2024-09-15", "Rock", []string{"https://www.example.com/musicians/jane-doe", "https://www.example.com/musicians/john-doe"}, )
// Rendering the HTML meta tags using templ:
templ Page() { @musicAlbum.ToMetaTgs() }
// Rendering the HTML meta tags as `template.HTML` value:
metaTagsHtml := musicAlbum.ToGoHTMLMetaTgs()
Expected output:
<meta property="og:type" content="music.album"/> <meta property="og:title" content="Example Album Title"/> <meta property="og:url" content="https://www.example.com/music/album/example-album"/> <meta property="og:description" content="This is an example album description."/> <meta property="og:image" content="https://www.example.com/images/album.jpg"/> <meta property="music:release_date" content="2024-09-15"/> <meta property="music:genre" content="Rock"/> <meta property="music:musician" content="https://www.example.com/musicians/jane-doe"/> <meta property="music:musician" content="https://www.example.com/musicians/john-doe"/>
func NewMusicAlbum ¶
func NewMusicAlbum(title, url, description, image, releaseDate, genre string, musician []string) *MusicAlbum
NewMusicAlbum initializes a MusicAlbum with the default type "music.album".
func (*MusicAlbum) ToGoHTMLMetaTags ¶
func (ma *MusicAlbum) ToGoHTMLMetaTags() (template.HTML, error)
ToGoHTMLMetaTags generates the HTML meta tags for the Open Graph Music Album as `template.HTML` value for Go's `html/template`.
func (*MusicAlbum) ToMetaTags ¶
func (ma *MusicAlbum) ToMetaTags() templ.Component
ToMetaTags generates the HTML meta tags for the Open Graph Music Album as templ.Component.
type MusicPlaylist ¶
type MusicPlaylist struct { OpenGraphObject SongURLs []string // music:song, URLs to the songs in the playlist Duration string // music:duration, duration of the playlist in seconds }
MusicPlaylist represents the Open Graph music playlist metadata. For more details about the meaning of the properties see: https://ogp.me/#type_music.playlist
Example usage:
Pure struct usage:
// Create a music playlist using pure struct musicPlaylist := &opengraph.MusicPlaylist{ OpenGraphObject: opengraph.OpenGraphObject{ Title: "Example Playlist Title", URL: "https://www.example.com/music/playlist/example-playlist", Description: "This is an example playlist description.", Image: "https://www.example.com/images/playlist.jpg", }, SongURLs: []string{"https://www.example.com/musicians/jane-doe", "https://www.example.com/musicians/john-doe"}, Duration: "60", }
Factory method usage:
// Create a music playlist musicPlaylist := opengraph.NewMusicPlaylist( "Example Playlist Title", "https://www.example.com/music/playlist/example-playlist", "This is an example playlist description.", "https://www.example.com/images/playlist.jpg", []string{"https://www.example.com/musicians/jane-doe", "https://www.example.com/musicians/john-doe"}, "60", )
// Rendering the HTML meta tags using templ:
templ Page() { @musicPlaylist.ToMetaTgs() }
// Rendering the HTML meta tags as `template.HTML` value:
metaTagsHtml := musicAlbum.ToGoHTMLMetaTgs()
Expected output:
<meta property="og:type" content="music.playlist"/> <meta property="og:title" content="Example Playlist Title"/> <meta property="og:url" content="https://www.example.com/music/playlist/example-playlist"/> <meta property="og:description" content="This is an example playlist description."/> <meta property="og:image" content="https://www.example.com/images/playlist.jpg"/> <meta property="music:song" content="https://www.example.com/musicians/jane-doe"/> <meta property="music:song" content="https://www.example.com/musicians/john-doe"/> <meta property="music:duration" content="60"/>
func NewMusicPlaylist ¶
func NewMusicPlaylist(title, url, description, image string, songURLs []string, duration string) *MusicPlaylist
NewMusicPlaylist initializes a MusicPlaylist with the default type "music.playlist".
func (*MusicPlaylist) ToGoHTMLMetaTags ¶
func (mp *MusicPlaylist) ToGoHTMLMetaTags() (template.HTML, error)
ToGoHTMLMetaTags generates the HTML meta tags for the Open Graph Music Playlist as `template.HTML` value for Go's `html/template`.
func (*MusicPlaylist) ToMetaTags ¶
func (mp *MusicPlaylist) ToMetaTags() templ.Component
ToMetaTags generates the HTML meta tags for the Open Graph Music Playlist as templ.Component.
type MusicRadioStation ¶
type MusicRadioStation struct {
OpenGraphObject
}
MusicRadioStation represents the Open Graph music radio station metadata. For more details about the meaning of the properties see: https://ogp.me/#type_music.radio_station
Example usage:
Pure struct usage:
// Create a music radio station using pure struct musicRadioStation := &opengraph.MusicRadioStation{ OpenGraphObject: opengraph.OpenGraphObject{ Title: "Example Radio Station", URL: "https://www.example.com/music/radio/example-radio", Description: "This is an example radio station description.", Image: "https://www.example.com/images/radio.jpg", }, }
Factory method usage:
// Create a music radio station using the factory method musicRadioStation := opengraph.NewMusicRadioStation( "Example Radio Station", "https://www.example.com/music/radio/example-radio", "This is an example radio station description.", "https://www.example.com/images/radio.jpg", )
// Rendering the HTML meta tags using templ:
templ Page() { @musicRadioStation.ToMetaTgs() }
// Rendering the HTML meta tags as `template.HTML` value:
metaTagsHtml := musicRadioStation.ToGoHTMLMetaTgs()
Expected output:
<meta property="og:type" content="music.radio_station"/> <meta property="og:title" content="Example Radio Station"/> <meta property="og:url" content="https://www.example.com/music/radio/example-radio"/> <meta property="og:description" content="This is an example radio station description."/> <meta property="og:image" content="https://www.example.com/images/radio.jpg"/>
func NewMusicRadioStation ¶
func NewMusicRadioStation(title, url, description, image string) *MusicRadioStation
NewMusicRadioStation initializes a MusicRadioStation with the default type "music.radio_station".
func (*MusicRadioStation) ToGoHTMLMetaTags ¶
func (mrs *MusicRadioStation) ToGoHTMLMetaTags() (template.HTML, error)
ToGoHTMLMetaTags generates the HTML meta tags for the Open Graph Music Radio Station as `template.HTML` value for Go's `html/template`.
func (*MusicRadioStation) ToMetaTags ¶
func (mrs *MusicRadioStation) ToMetaTags() templ.Component
ToMetaTags generates the HTML meta tags for the Open Graph Music Radio Station as templ.Component.
type MusicSong ¶
type MusicSong struct { OpenGraphObject Duration string // music:duration, duration of the song in seconds AlbumURL string // music:album, URL to the album MusicianURLs []string // music:musician, URLs to the musicians }
MusicSong represents the Open Graph music song metadata. For more details about the meaning of the properties see: https://ogp.me/#type_music.song
Example usage:
Pure struct usage:
// Create a music song using pure struct musicSong := &opengraph.MusicSong{ OpenGraphObject: opengraph.OpenGraphObject{ Title: "Example Song Title", URL: "https://www.example.com/music/song/example-song", Description: "This is an example song description.", Image: "https://www.example.com/images/song.jpg", }, Duration: "240", // Duration in seconds AlbumURL: "https://www.example.com/music/album/example-album", MusicianURLs: []string{ "https://www.example.com/musicians/jane-doe", "https://www.example.com/musicians/john-doe", }, }
Factory method usage:
// Create a music song using the factory method musicSong := opengraph.NewMusicSong( "Example Song Title", "https://www.example.com/music/song/example-song", "This is an example song description.", "https://www.example.com/images/song.jpg", "240", // Duration in seconds "https://www.example.com/music/album/example-album", []string{"https://www.example.com/musicians/jane-doe", "https://www.example.com/musicians/john-doe"}, )
// Rendering the HTML meta tags using templ:
templ Page() { @musicSong.ToMetaTgs() }
// Rendering the HTML meta tags as `template.HTML` value:
metaTagsHtml := musicSong.ToGoHTMLMetaTgs()
Expected output:
<meta property="og:type" content="music.song"/> <meta property="og:title" content="Example Song Title"/> <meta property="og:url" content="https://www.example.com/music/song/example-song"/> <meta property="og:description" content="This is an example song description."/> <meta property="og:image" content="https://www.example.com/images/song.jpg"/> <meta property="music:duration" content="240"/> <meta property="music:album" content="https://www.example.com/music/album/example-album"/> <meta property="music:musician" content="https://www.example.com/musicians/jane-doe"/> <meta property="music:musician" content="https://www.example.com/musicians/john-doe"/>
func NewMusicSong ¶
func NewMusicSong(title, url, description, image, duration, albumURL string, musicianURLs []string) *MusicSong
NewMusicSong initializes a MusicSong with the default type "music.song".
func (*MusicSong) ToGoHTMLMetaTags ¶
ToGoHTMLMetaTags generates the HTML meta tags for the Open Graph Music Song as `template.HTML` value for Go's `html/template`.
func (*MusicSong) ToMetaTags ¶
ToMetaTags generates the HTML meta tags for the Open Graph Music Song as templ.Component.
type OpenGraphObject ¶
type OpenGraphObject struct { Type string // og:type, the type of the object Title string // og:title, the title of the object URL string // og:url, the canonical URL of the object Description string // og:description, a brief description of the object Image string // og:image, URL to the image of the object }
OpenGraphObject represents common Open Graph metadata. For more details about the meaning of the properties see: https://ogp.me/#metadata
type Place ¶
type Place struct { OpenGraphObject Latitude float64 // place:location:latitude, latitude of the place Longitude float64 // place:location:longitude, longitude of the place StreetAddress string // place:contact_data:street_address, street address of the place Locality string // place:contact_data:locality, locality or city of the place Region string // place:contact_data:region, region or state of the place PostalCode string // place:contact_data:postal_code, postal code of the place Country string // place:contact_data:country_name, country of the place }
Place represents the Open Graph place metadata. For more details about the meaning of the properties see: https://ogp.me/#metadata
Example usage:
Pure struct usage:
// Create a place using pure struct place := &opengraph.Place{ OpenGraphObject: opengraph.OpenGraphObject{ Title: "Example Place", URL: "https://www.example.com/place/example-place", Description: "This is an example place description.", Image: "https://www.example.com/images/place.jpg", }, Latitude: 40.7128, // Example latitude Longitude: -74.0060, // Example longitude StreetAddress: "123 Main St", Locality: "New York", Region: "NY", PostalCode: "10001", Country: "USA", }
Factory method usage:
// Create a place using the factory method place := opengraph.NewPlace( "Example Place", "https://www.example.com/place/example-place", "This is an example place description.", "https://www.example.com/images/place.jpg", 40.7128, // Latitude -74.0060, // Longitude "123 Main St", "New York", "NY", "10001", "USA", )
// Rendering the HTML meta tags using templ:
templ Page() { @place.ToMetaTgs() }
// Rendering the HTML meta tags as `template.HTML` value:
metaTagsHtml := place.ToGoHTMLMetaTgs()
Expected output:
<meta property="og:type" content="place"/> <meta property="og:title" content="Example Place"/> <meta property="og:url" content="https://www.example.com/place/example-place"/> <meta property="og:description" content="This is an example place description."/> <meta property="og:image" content="https://www.example.com/images/place.jpg"/> <meta property="place:location:latitude" content="40.7128"/> <meta property="place:location:longitude" content="-74.0060"/> <meta property="place:contact_data:street_address" content="123 Main St"/> <meta property="place:contact_data:locality" content="New York"/> <meta property="place:contact_data:region" content="NY"/> <meta property="place:contact_data:postal_code" content="10001"/> <meta property="place:contact_data:country_name" content="USA"/>
func NewPlace ¶
func NewPlace(title, url, description, image string, latitude, longitude float64, streetAddress, locality, region, postalCode, country string) *Place
NewPlace initializes a Place with the default type "place".
func (*Place) ToGoHTMLMetaTags ¶
ToGoHTMLMetaTags generates the HTML meta tags for the Open Graph Place as `template.HTML` value for Go's `html/template`.
func (*Place) ToMetaTags ¶
ToMetaTags generates the HTML meta tags for the Open Graph Place as templ.Component.
type Product ¶
type Product struct { OpenGraphObject Price string // product:price:amount, price of the product PriceCurrency string // product:price:currency, currency of the price }
Product represents the Open Graph product metadata. For more details about the meaning of the properties see: https://ogp.me/#metadata
Example usage:
Pure struct usage:
// Create a product using pure struct product := &opengraph.Product{ OpenGraphObject: opengraph.OpenGraphObject{ Title: "Example Product", URL: "https://www.example.com/product/example-product", Description: "This is an example product description.", Image: "https://www.example.com/images/product.jpg", }, Price: "29.99", PriceCurrency: "USD", }
Factory method usage:
// Create a product product := opengraph.NewProduct( "Example Product", "https://www.example.com/product/example-product", "This is an example product description.", "https://www.example.com/images/product.jpg", "29.99", "USD", )
// Rendering the HTML meta tags using templ:
templ Page() { @product.ToMetaTgs() }
// Rendering the HTML meta tags as `template.HTML` value:
metaTagsHtml := product.ToGoHTMLMetaTgs()
Expected output:
<meta property="og:type" content="product"/> <meta property="og:title" content="Example Product"/> <meta property="og:url" content="https://www.example.com/product/example-product"/> <meta property="og:description" content="This is an example product description."/> <meta property="og:image" content="https://www.example.com/images/product.jpg"/> <meta property="product:price:amount" content="29.99"/> <meta property="product:price:currency" content="USD"/>
func NewProduct ¶
NewProduct initializes a Product with the default type "product".
func (*Product) ToGoHTMLMetaTags ¶
ToGoHTMLMetaTags generates the HTML meta tags for the Open Graph Product as `template.HTML` value for Go's `html/template`.
func (*Product) ToMetaTags ¶
ToMetaTags generates the HTML meta tags for the Open Graph Product as templ.Component.
type ProductGroup ¶
type ProductGroup struct { OpenGraphObject Products []string // product:group_item, URLs to individual products in the group }
ProductGroup represents the Open Graph product group metadata. For more details about the meaning of the properties see: https://ogp.me/#metadata
Example usage:
Pure struct usage:
// Create a product group using pure struct productGroup := &opengraph.ProductGroup{ OpenGraphObject: opengraph.OpenGraphObject{ Title: "Example Product Group", URL: "https://www.example.com/product-group/example-product-group", Description: "This is an example product group description.", Image: "https://www.example.com/images/product-group.jpg", }, Products: []string{ "https://www.example.com/product/product-1", "https://www.example.com/product/product-2", }, }
Factory method usage:
// Create a product group using the factory method productGroup := opengraph.NewProductGroup( "Example Product Group", "https://www.example.com/product-group/example-product-group", "This is an example product group description.", "https://www.example.com/images/product-group.jpg", []string{ "https://www.example.com/product/product-1", "https://www.example.com/product/product-2", }, )
// Rendering the HTML meta tags using templ:
templ Page() { @productGroup.ToMetaTgs() }
// Rendering the HTML meta tags as `template.HTML` value:
metaTagsHtml := productGroup.ToGoHTMLMetaTgs()
Expected output:
<meta property="og:type" content="product.group"/> <meta property="og:title" content="Example Product Group"/> <meta property="og:url" content="https://www.example.com/product-group/example-product-group"/> <meta property="og:description" content="This is an example product group description."/> <meta property="og:image" content="https://www.example.com/images/product-group.jpg"/> <meta property="product:group_item" content="https://www.example.com/product/product-1"/> <meta property="product:group_item" content="https://www.example.com/product/product-2"/>
func NewProductGroup ¶
func NewProductGroup(title, url, description, image string, products []string) *ProductGroup
NewProductGroup initializes a ProductGroup with the default type "product.group".
func (*ProductGroup) ToGoHTMLMetaTags ¶
func (pg *ProductGroup) ToGoHTMLMetaTags() (template.HTML, error)
ToGoHTMLMetaTags generates the HTML meta tags for the Open Graph Product Group as `template.HTML` value for Go's `html/template`.
func (*ProductGroup) ToMetaTags ¶
func (pg *ProductGroup) ToMetaTags() templ.Component
ToMetaTags generates the HTML meta tags for the Open Graph Product Group as templ.Component.
type Profile ¶
type Profile struct { OpenGraphObject FirstName string // profile:first_name, first name LastName string // profile:last_name, last name Username string // profile:username, username Gender string // profile:gender, gender }
Profile represents the Open Graph profile metadata. For more details about the meaning of the properties see: https://ogp.me/#type_profile
Example usage:
Pure struct usage:
// Create a profile using pure struct profile := &opengraph.Profile{ OpenGraphObject: opengraph.OpenGraphObject{ Title: "John Doe", URL: "https://www.example.com/profile/johndoe", Description: "This is John Doe's profile.", Image: "https://www.example.com/images/profile.jpg", }, FirstName: "John", LastName: "Doe", Username: "johndoe", Gender: "male", }
Factory method usage:
// Create a profile profile := opengraph.NewProfile( "John Doe", "John", "Doe", "johndoe", "male", "https://www.example.com/profile/johndoe", "This is John Doe's profile.", "https://www.example.com/images/profile.jpg", )
// Rendering the HTML meta tags using templ:
templ Page() { @profile.ToMetaTgs() }
// Rendering the HTML meta tags as `template.HTML` value:
metaTagsHtml := profile.ToGoHTMLMetaTgs()
Expected output:
<meta property="og:type" content="profile"/> <meta property="og:title" content="John Doe"/> <meta property="profile:first_name" content="John"/> <meta property="profile:last_name" content="Doe"/> <meta property="profile:username" content="johndoe"/> <meta property="profile:gender" content="male"/> <meta property="og:url" content="https://www.example.com/profile/johndoe"/> <meta property="og:description" content="This is John Doe's profile."/> <meta property="og:image" content="https://www.example.com/images/profile.jpg"/>
func NewProfile ¶
func NewProfile(title string, firstName string, lastName string, username string, gender string, url string, description string, image string) *Profile
NewProfile initializes an OpenGraphProfile with the default type "profile".
func (*Profile) ToGoHTMLMetaTags ¶
ToGoHTMLMetaTags generates the HTML meta tags for the Open Graph Profile as `template.HTML` value for Go's `html/template`.
func (*Profile) ToMetaTags ¶
ToMetaTags generates the HTML meta tags for the Open Graph Profile as templ.Component.
type Restaurant ¶
type Restaurant struct { OpenGraphObject StreetAddress string // place:contact_data:street_address, street address of the restaurant Locality string // place:contact_data:locality, locality or city of the restaurant Region string // place:contact_data:region, region or state of the restaurant PostalCode string // place:contact_data:postal_code, postal code of the restaurant Country string // place:contact_data:country_name, country of the restaurant Phone string // place:contact_data:phone_number, phone number of the restaurant MenuURL string // restaurant:menu, URL to the restaurant's menu ReservationURL string // restaurant:reservation, URL to the reservation page }
Restaurant represents the Open Graph restaurant metadata. For more details about the meaning of the properties see: https://ogp.me/#metadata
Example usage:
Pure struct usage:
// Create a restaurant using pure struct restaurant := &opengraph.Restaurant{ OpenGraphObject: opengraph.OpenGraphObject{ Title: "Example Restaurant", URL: "https://www.example.com/restaurant/example-restaurant", Description: "This is an example restaurant description.", Image: "https://www.example.com/images/restaurant.jpg", }, StreetAddress: "123 Food Street", Locality: "Gourmet City", Region: "CA", PostalCode: "12345", Country: "USA", Phone: "+1-800-FOOD-123", MenuURL: "https://www.example.com/menu", ReservationURL: "https://www.example.com/reservations", }
Factory method usage:
// Create a restaurant using the factory method restaurant := opengraph.NewRestaurant( "Example Restaurant", "https://www.example.com/restaurant/example-restaurant", "This is an example restaurant description.", "https://www.example.com/images/restaurant.jpg", "123 Food Street", "Gourmet City", "CA", "12345", "USA", "+1-800-FOOD-123", "https://www.example.com/menu", "https://www.example.com/reservations", )
// Rendering the HTML meta tags using templ:
templ Page() { @restaurant.ToMetaTgs() }
// Rendering the HTML meta tags as `template.HTML` value:
metaTagsHtml := restaurant.ToGoHTMLMetaTgs()
Expected output:
<meta property="og:type" content="restaurant"/> <meta property="og:title" content="Example Restaurant"/> <meta property="og:url" content="https://www.example.com/restaurant/example-restaurant"/> <meta property="og:description" content="This is an example restaurant description."/> <meta property="og:image" content="https://www.example.com/images/restaurant.jpg"/> <meta property="place:contact_data:street_address" content="123 Food Street"/> <meta property="place:contact_data:locality" content="Gourmet City"/> <meta property="place:contact_data:region" content="CA"/> <meta property="place:contact_data:postal_code" content="12345"/> <meta property="place:contact_data:country_name" content="USA"/> <meta property="place:contact_data:phone_number" content="+1-800-FOOD-123"/> <meta property="restaurant:menu" content="https://www.example.com/menu"/> <meta property="restaurant:reservation" content="https://www.example.com/reservations"/>
func NewRestaurant ¶
func NewRestaurant(title, url, description, image, streetAddress, locality, region, postalCode, country, phone, menuURL, reservationURL string) *Restaurant
NewRestaurant initializes a Restaurant with the default type "restaurant".
func (*Restaurant) ToGoHTMLMetaTags ¶
func (restaurant *Restaurant) ToGoHTMLMetaTags() (template.HTML, error)
ToGoHTMLMetaTags generates the HTML meta tags for the Open Graph Restaurant as `template.HTML` value for Go's `html/template`.
func (*Restaurant) ToMetaTags ¶
func (restaurant *Restaurant) ToMetaTags() templ.Component
ToMetaTags generates the HTML meta tags for the Open Graph Restaurant as templ.Component.
type Video ¶
type Video struct { OpenGraphObject Duration string // video:duration, duration of the video in seconds ActorURLs []string // video:actor, URLs to the actors in the video DirectorURL string // video:director, URL to the director of the video ReleaseDate string // video:release_date, the release date of the video }
Video represents the Open Graph video metadata. For more details about the meaning of the properties see: https://ogp.me/#type_video Example usage:
Pure struct usage:
// Create a video using pure struct video := &opengraph.Video{ OpenGraphObject: opengraph.OpenGraphObject{ Title: "Example Video", URL: "https://www.example.com/video/example-video", Description: "This is an example video description.", Image: "https://www.example.com/images/video.jpg", }, Duration: "300", // Duration in seconds ActorURLs: []string{ "https://www.example.com/actors/jane-doe", "https://www.example.com/actors/john-doe", }, DirectorURL: "https://www.example.com/directors/jane-director", ReleaseDate: "2024-09-15", }
Factory method usage:
// Create a video using the factory method video := opengraph.NewVideo( "Example Video", "https://www.example.com/video/example-video", "This is an example video description.", "https://www.example.com/images/video.jpg", "300", // Duration in seconds []string{"https://www.example.com/actors/jane-doe", "https://www.example.com/actors/john-doe"}, "https://www.example.com/directors/jane-director", "2024-09-15", )
// Rendering the HTML meta tags using templ:
templ Page() { @video.ToMetaTgs() }
// Rendering the HTML meta tags as `template.HTML` value:
metaTagsHtml := video.ToGoHTMLMetaTgs()
Expected output:
<meta property="og:type" content="video.movie"/> <meta property="og:title" content="Example Video"/> <meta property="og:url" content="https://www.example.com/video/example-video"/> <meta property="og:description" content="This is an example video description."/> <meta property="og:image" content="https://www.example.com/images/video.jpg"/> <meta property="video:duration" content="300"/> <meta property="video:actor" content="https://www.example.com/actors/jane-doe"/> <meta property="video:actor" content="https://www.example.com/actors/john-doe"/> <meta property="video:director" content="https://www.example.com/directors/jane-director"/> <meta property="video:release_date" content="2024-09-15"/>
func NewVideo ¶
func NewVideo(title, url, description, image, duration string, actorURLs []string, directorURL, releaseDate string) *Video
NewVideo initializes a Video with the default type "video.movie".
func (*Video) ToGoHTMLMetaTags ¶
ToGoHTMLMetaTags generates the HTML meta tags for the Open Graph Video as `template.HTML` value for Go's `html/template`.
func (*Video) ToMetaTags ¶
ToMetaTags generates the HTML meta tags for the Open Graph Video using templ.Component.
type VideoEpisode ¶
type VideoEpisode struct { OpenGraphObject SeriesURL string // video:series, URL to the video series Duration string // video:duration, duration of the episode in seconds ActorURLs []string // video:actor, URLs to the actors in the episode DirectorURL string // video:director, URL to the director of the episode ReleaseDate string // video:release_date, the release date of the episode EpisodeNumber int // video:episode, the episode number in the series }
VideoEpisode represents the Open Graph video episode metadata. For more details about the meaning of the properties see: https://ogp.me/#type_video.episode
Example usage:
Pure struct usage:
// Create a video episode using pure struct videoEpisode := &opengraph.VideoEpisode{ OpenGraphObject: opengraph.OpenGraphObject{ Title: "Example Video Episode", URL: "https://www.example.com/video/episode/example-episode", Description: "This is an example video episode description.", Image: "https://www.example.com/images/episode.jpg", }, SeriesURL: "https://www.example.com/video/series/example-series", Duration: "1800", // Duration in seconds ActorURLs: []string{"https://www.example.com/actors/jane-doe", "https://www.example.com/actors/john-doe"}, DirectorURL: "https://www.example.com/directors/jane-director", ReleaseDate: "2024-09-15", EpisodeNumber: 1, }
Factory method usage:
// Create a video episode using the factory method videoEpisode := opengraph.NewVideoEpisode( "Example Video Episode", "https://www.example.com/video/episode/example-episode", "This is an example video episode description.", "https://www.example.com/images/episode.jpg", "1800", // Duration in seconds "https://www.example.com/video/series/example-series", []string{"https://www.example.com/actors/jane-doe", "https://www.example.com/actors/john-doe"}, "https://www.example.com/directors/jane-director", "2024-09-15", 1, // Episode number )
// Rendering the HTML meta tags using templ:
templ Page() { @videoEpisode.ToMetaTgs() }
// Rendering the HTML meta tags as `template.HTML` value:
metaTagsHtml := videoEpisode.ToGoHTMLMetaTgs()
Expected output:
<meta property="og:type" content="video.episode"/> <meta property="og:title" content="Example Video Episode"/> <meta property="og:url" content="https://www.example.com/video/episode/example-episode"/> <meta property="og:description" content="This is an example video episode description."/> <meta property="og:image" content="https://www.example.com/images/episode.jpg"/> <meta property="video:duration" content="1800"/> <meta property="video:actor" content="https://www.example.com/actors/jane-doe"/> <meta property="video:actor" content="https://www.example.com/actors/john-doe"/> <meta property="video:director" content="https://www.example.com/directors/jane-director"/> <meta property="video:release_date" content="2024-09-15"/> <meta property="video:series" content="https://www.example.com/video/series/example-series"/> <meta property="video:episode" content="1"/>
func NewVideoEpisode ¶
func NewVideoEpisode(title, url, description, image, duration, seriesURL string, actorURLs []string, directorURL, releaseDate string, episodeNumber int) *VideoEpisode
NewVideoEpisode initializes a VideoEpisode with the default type "video.episode".
func (*VideoEpisode) ToGoHTMLMetaTags ¶
func (ve *VideoEpisode) ToGoHTMLMetaTags() (template.HTML, error)
ToGoHTMLMetaTags generates the HTML meta tags for the Open Graph Video Episode as `template.HTML` value for Go's `html/template`.
func (*VideoEpisode) ToMetaTags ¶
func (ve *VideoEpisode) ToMetaTags() templ.Component
ToMetaTags generates the HTML meta tags for the Open Graph Video Episode as templ.Component.
type VideoMovie ¶
type VideoMovie struct { OpenGraphObject Duration string // video:duration, duration of the movie in seconds ActorURLs []string // video:actor, URLs to the actors in the movie DirectorURL string // video:director, URL to the director of the movie ReleaseDate string // video:release_date, the release date of the movie }
VideoMovie represents the Open Graph video movie metadata. For more details about the meaning of the properties see: https://ogp.me/#type_video.movie
Example usage:
Pure struct usage:
// Create a video movie using pure struct videoMovie := &opengraph.VideoMovie{ OpenGraphObject: opengraph.OpenGraphObject{ Title: "Example Movie", URL: "https://www.example.com/video/movie/example-movie", Description: "This is an example movie description.", Image: "https://www.example.com/images/movie.jpg", }, Duration: "7200", // Duration in seconds (2 hours) ActorURLs: []string{"https://www.example.com/actors/jane-doe", "https://www.example.com/actors/john-doe"}, DirectorURL: "https://www.example.com/directors/jane-director", ReleaseDate: "2024-09-15", }
Factory method usage:
// Create a video movie using the factory method videoMovie := opengraph.NewVideoMovie( "Example Movie", "https://www.example.com/video/movie/example-movie", "This is an example movie description.", "https://www.example.com/images/movie.jpg", "7200", // Duration in seconds (2 hours) []string{"https://www.example.com/actors/jane-doe", "https://www.example.com/actors/john-doe"}, "https://www.example.com/directors/jane-director", "2024-09-15", )
// Rendering the HTML meta tags using templ:
templ Page() { @videoMovie.ToMetaTgs() }
// Rendering the HTML meta tags as `template.HTML` value:
metaTagsHtml := videoMovie.ToGoHTMLMetaTgs()
Expected output:
<meta property="og:type" content="video.movie"/> <meta property="og:title" content="Example Movie"/> <meta property="og:url" content="https://www.example.com/video/movie/example-movie"/> <meta property="og:description" content="This is an example movie description."/> <meta property="og:image" content="https://www.example.com/images/movie.jpg"/> <meta property="video:duration" content="7200"/> <meta property="video:actor" content="https://www.example.com/actors/jane-doe"/> <meta property="video:actor" content="https://www.example.com/actors/john-doe"/> <meta property="video:director" content="https://www.example.com/directors/jane-director"/> <meta property="video:release_date" content="2024-09-15"/>
func NewVideoMovie ¶
func NewVideoMovie(title, url, description, image, duration string, actorURLs []string, directorURL, releaseDate string) *VideoMovie
NewVideoMovie initializes a VideoMovie with the default type "video.movie".
func (*VideoMovie) ToGoHTMLMetaTags ¶
func (vm *VideoMovie) ToGoHTMLMetaTags() (template.HTML, error)
ToGoHTMLMetaTags generates the HTML meta tags for the Open Graph Video Movie as `template.HTML` value for Go's `html/template`.
func (*VideoMovie) ToMetaTags ¶
func (vm *VideoMovie) ToMetaTags() templ.Component
ToMetaTags generates the HTML meta tags for the Open Graph Video Movie as templ.Component.
type WebSite ¶
type WebSite struct {
OpenGraphObject
}
WebSite represents the Open Graph website metadata. For more details about the meaning of the properties see: https://ogp.me/#type_website
Example usage:
Pure struct usage:
// Create a website using pure struct website := &opengraph.WebSite{ OpenGraphObject: opengraph.OpenGraphObject{ Title: "Example Website", URL: "https://www.example.com", Description: "This is an example website description.", Image: "https://www.example.com/images/logo.jpg", }, }
Factory method usage:
// Create a website using the factory method website := opengraph.NewWebSite( "Example Website", "https://www.example.com", "This is an example website description.", "https://www.example.com/images/logo.jpg", )
// Rendering the HTML meta tags using templ:
templ Page() { @website.ToMetaTgs() }
// Rendering the HTML meta tags as `template.HTML` value:
metaTagsHtml := website.ToGoHTMLMetaTgs()
Expected output:
<meta property="og:type" content="website"/> <meta property="og:title" content="Example Website"/> <meta property="og:url" content="https://www.example.com"/> <meta property="og:description" content="This is an example website description."/> <meta property="og:image" content="https://www.example.com/images/logo.jpg"/>
func NewWebSite ¶
NewWebSite initializes a WebSite with the default type "website".
func (*WebSite) ToGoHTMLMetaTags ¶
ToGoHTMLMetaTags generates the HTML meta tags for the Open Graph WebSite as `template.HTML` value for Go's `html/template`.
func (*WebSite) ToMetaTags ¶
ToMetaTags generates the HTML meta tags for the Open Graph WebSite using templ.Component.