Documentation ¶
Index ¶
- type Action
- type AggregateRating
- type Answer
- type Article
- type Brand
- type BreadcrumbList
- type ContactPoint
- type Event
- type FAQPage
- type GeoCoordinates
- type ImageObject
- type ItemList
- type ItemListElement
- type ListItem
- type LocalBusiness
- type Offer
- type Organization
- type Person
- type Place
- type PostalAddress
- type Product
- type Question
- type Rating
- type Review
- type SiteNavigationElement
- type Target
- type WebPage
- type WebSite
- type XMLSitemap
- type XMLSitemapUrl
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct { Type string `json:"@type"` Target *Target `json:"target"` QueryInput string `json:"query-input"` }
Action represents a Schema.org Action object
type AggregateRating ¶
type AggregateRating struct { Type string `json:"@type"` RatingValue float64 `json:"ratingValue,omitempty"` ReviewCount int `json:"reviewCount,omitempty"` }
AggregateRating represents a Schema.org AggregateRating object
type Article ¶
type Article struct { Context string `json:"@context"` Type string `json:"@type"` Headline string `json:"headline,omitempty"` Image []string `json:"image,omitempty"` Author *Person `json:"author,omitempty"` Publisher *Organization `json:"publisher,omitempty"` DatePublished string `json:"datePublished,omitempty"` DateModified string `json:"dateModified,omitempty"` Description string `json:"description,omitempty"` }
Article represents a Schema.org Article object. For more details about the meaning of the properties see: https://schema.org/Article
Example usage:
Pure struct usage:
article := &schemaorg.Article{ Headline: "Example Article Headline", Image: []string{"https://www.example.com/images/article.jpg"}, Author: &schemaorg.Person{Name: "Jane Doe"}, Publisher: &schemaorg.Organization{Name: "Example Publisher"}, DatePublished: "2024-09-15", DateModified: "2024-09-16", Description: "This is an example article.", }
Factory method usage:
article := schemaorg.NewArticle( "Example Article Headline", []string{"https://www.example.com/images/article.jpg"}, &schemaorg.Person{Name: "Jane Doe"}, &schemaorg.Organization{Name: "Example Publisher"}, "2024-09-15", "2024-09-16", "This is an example article", )
// Rendering JSON-LD using templ:
templ Page() { @article.ToJsonLd() }
// Rendering JSON-LD as `template.HTML` value:
jsonLdHtml := article.ToGoHTMLJsonLd()
Expected output:
{ "@context": "https://schema.org", "@type": "Article", "headline": "Example Article Headline", "image": ["https://www.example.com/images/article.jpg"], "author": {"@type": "Person", "name": "Jane Doe"}, "publisher": {"@type": "Organization", "name": "Example Publisher"}, "datePublished": "2024-09-15", "dateModified": "2024-09-16", "description": "This is an example article" }
func NewArticle ¶
func NewArticle(headline string, images []string, author *Person, publisher *Organization, datePublished, dateModified, description string) *Article
NewArticle initializes an Article with default context and type.
func (*Article) ToGoHTMLJsonLd ¶
ToGoHTMLJsonLd renders the Article struct as `template.HTML` value for Go's `html/template`.
type BreadcrumbList ¶
type BreadcrumbList struct { Context string `json:"@context"` Type string `json:"@type"` ItemListElement []ListItem `json:"itemListElement"` }
BreadcrumbList represents a Schema.org BreadcrumbList object. For more details about the meaning of the properties see:https://schema.org/BreadcrumbList
Example usage:
Pure struct usage:
breadcrumb := &schemaorg.BreadcrumbList{ ItemListElement: []schemaorg.ListItem{ {Name: "Home", Item: "https://www.example.com", Position: 1}, {Name: "About Us", Item: "https://www.example.com/about", Position: 2}, }, }
Factory method usage:
breadcrumb := schemaorg.NewBreadcrumbList( []schemaorg.ListItem{ {Name: "Home", Item: "https://www.example.com", Position: 1}, {Name: "About Us", Item: "https://www.example.com/about", Position: 2}, }, )
Example usage with `NewBreadcrumbListFromUrl`:
func HandleAbout(w http.ResponseWriter, r *http.Request) { pageURL := teseo.GetFullURL(r) breadcrumbList, err := schemaorg.NewBreadcrumbListFromUrl(pageURL) if err != nil { fmt.Println("Error generating breadcrumb list:", err) return } // pass the component to your page and render with `@breadcrumbList.ToJsonLd()` err = pages.AboutPage(breadcrumbList).Render(r.Context(), w) if err != nil { return } }
// Rendering JSON-LD using templ:
templ Page() { @breadcrumb.ToJsonLd() }
// Rendering JSON-LD as `template.HTML` value:
jsonLdHtml := breadcrumb.ToGoHTMLJsonLd()
Expected output:
{ "@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [ {"@type": "ListItem", "position": 1, "name": "Home", "item": "https://www.example.com"}, {"@type": "ListItem", "position": 2, "name": "About Us", "item": "https://www.example.com/about"} ] }
func NewBreadcrumbList ¶
func NewBreadcrumbList(listItem []ListItem) *BreadcrumbList
NewBreadcrumbList initializes an BreadcrumbList with default context and type.
func NewBreadcrumbListFromUrl ¶
func NewBreadcrumbListFromUrl(url string) (*BreadcrumbList, error)
NewBreadcrumbListFromUrl initializes an BreadcrumbList from the URL string.
func (*BreadcrumbList) ToGoHTMLJsonLd ¶
func (bcl *BreadcrumbList) ToGoHTMLJsonLd() (template.HTML, error)
ToGoHTMLJsonLd renders the BreadcrumbList struct as `template.HTML` value for Go's `html/template`.
func (*BreadcrumbList) ToJsonLd ¶
func (bcl *BreadcrumbList) ToJsonLd() templ.Component
ToJsonLd converts the BreadcrumbList struct to a JSON-LD `templ.Component`.
type ContactPoint ¶
type ContactPoint struct { Type string `json:"@type"` Telephone string `json:"telephone,omitempty"` ContactType string `json:"contactType,omitempty"` AreaServed string `json:"areaServed,omitempty"` AvailableLanguage string `json:"availableLanguage,omitempty"` }
ContactPoint represents a Schema.org ContactPoint object For more details about the meaning of the properties see: https://schema.org/ContactPoint
type Event ¶
type Event struct { Context string `json:"@context"` Type string `json:"@type"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` StartDate string `json:"startDate,omitempty"` EndDate string `json:"endDate,omitempty"` Location *Place `json:"location,omitempty"` Organizer *Organization `json:"organizer,omitempty"` Performer *Person `json:"performer,omitempty"` Image []string `json:"image,omitempty"` EventStatus string `json:"eventStatus,omitempty"` EventAttendanceMode string `json:"eventAttendanceMode,omitempty"` Offers *Offer `json:"offers,omitempty"` }
Event represents a Schema.org Event object. For more details about the meaning of the properties see:https://schema.org/Event
Example usage:
Pure struct usage:
event := &schemaorg.Event{ Name: "Example Event", StartDate: "2024-09-20T19:00:00", EndDate: "2024-09-20T23:00:00", Location: &schemaorg.Place{Name: "Example Venue", Address: "123 Main St"}, Description: "This is an example event.", }
Factory method usage:
event := schemaorg.NewEvent( "Example Event", "2024-09-20T19:00:00", "2024-09-20T23:00:00", &schemaorg.Place{Name: "Example Venue", Address: "123 Main St"}, "This is an example event", )
// Rendering JSON-LD using templ:
templ Page() { @event.ToJsonLd() }
// Rendering JSON-LD as `template.HTML` value:
jsonLdHtml := event.ToGoHTMLJsonLd()
Expected output:
{ "@context": "https://schema.org", "@type": "Event", "name": "Example Event", "startDate": "2024-09-20T19:00:00", "endDate": "2024-09-20T23:00:00", "location": {"@type": "Place", "name": "Example Venue", "address": "123 Main St"}, "description": "This is an example event" }
func NewEvent ¶
func NewEvent(name, description, startDate, endDate string, location *Place, organizer *Organization, performer *Person, images []string, eventStatus, eventAttendanceMode string, offers *Offer) *Event
NewEvent initializes an Event with default context and type.
func (*Event) ToGoHTMLJsonLd ¶
ToGoHTMLJsonLd renders the Event struct as `template.HTML` value for Go's `html/template`.
type FAQPage ¶
type FAQPage struct { Context string `json:"@context"` Type string `json:"@type"` MainEntity []*Question `json:"mainEntity,omitempty"` }
FAQPage represents a Schema.org FAQPage object. For more details about the meaning of the properties see:https://schema.org/FAQPage
Example usage:
Pure struct usage:
faqPage := &schemaorg.FAQPage{ MainEntity: []schemaorg.Question{ {Question: "What is Schema.org?", Answer: &schemaorg.Answer{Answer: "Schema.org is a structured data vocabulary."}}, }, }
Factory method usage:
faqPage := schemaorg.NewFAQPage( []schemaorg.Question{ {Question: "What is Schema.org?", Answer: &schemaorg.Answer{Answer: "Schema.org is a structured data vocabulary."}}, }, )
// Rendering JSON-LD using templ:
templ Page() { @faqPage.ToJsonLd() }
// Rendering JSON-LD as `template.HTML` value:
jsonLdHtml := faqPage.ToGoHTMLJsonLd()
Expected output:
{ "@context": "https://schema.org", "@type": "FAQPage", "mainEntity": [ { "@type": "Question", "name": "What is Schema.org?", "acceptedAnswer": {"@type": "Answer", "text": "Schema.org is a structured data vocabulary."} } ] }
func NewFAQPage ¶
NewFAQPage initializes an FAQPage with default context and type.
func (*FAQPage) ToGoHTMLJsonLd ¶
ToGoHTMLJsonLd renders the FAQPage struct as`template.HTML` value for Go's `html/template`.
type GeoCoordinates ¶
type GeoCoordinates struct { Type string `json:"@type"` Latitude float64 `json:"latitude,omitempty"` Longitude float64 `json:"longitude,omitempty"` }
GeoCoordinates represents a Schema.org GeoCoordinates object
type ImageObject ¶
ImageObject represents a Schema.org ImageObject object For more details about the meaning of the properties see: https://schema.org/ImageObject
type ItemList ¶
type ItemList struct { Context string `json:"@context"` Type string `json:"@type"` ItemListElement []ItemListElement `json:"itemListElement"` }
ItemList represents a Schema.org ItemList object
func NewItemList ¶
func NewItemList(elements []ItemListElement) ItemList
NewItemList creates a new ItemList with default values.
type ItemListElement ¶
type ItemListElement struct { Type string `json:"@type"` Name string `json:"name,omitempty"` URL string `json:"url,omitempty"` Position int `json:"position,omitempty"` }
ItemListElement represents an individual item in an ItemList
func NewItemListElement ¶
func NewItemListElement(name, url string, position int) ItemListElement
NewItemListElement creates a new ItemListElement with default values.
type ListItem ¶
type ListItem struct { Type string `json:"@type"` Position int `json:"position,omitempty"` Name string `json:"name,omitempty"` Item string `json:"item,omitempty"` }
ListItem represents a Schema.org ListItem object For more details about the meaning of the properties see: https://schema.org/ListItem
type LocalBusiness ¶
type LocalBusiness struct { Context string `json:"@context"` Type string `json:"@type"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` URL string `json:"url,omitempty"` Logo *ImageObject `json:"logo,omitempty"` Telephone string `json:"telephone,omitempty"` Address *PostalAddress `json:"address,omitempty"` OpeningHours []string `json:"openingHours,omitempty"` Geo *GeoCoordinates `json:"geo,omitempty"` AggregateRating *AggregateRating `json:"aggregateRating,omitempty"` Review []*Review `json:"review,omitempty"` }
LocalBusiness represents a Schema.org LocalBusiness object. For more details about the meaning of the properties see:https://schema.org/LocalBusiness
Example usage:
Pure struct usage:
localBusiness := &schemaorg.LocalBusiness{ Name: "Example Business", Address: &schemaorg.PostalAddress{StreetAddress: "123 Main St", AddressLocality: "Anytown", AddressRegion: "CA", PostalCode: "12345"}, Telephone: "+1-800-555-1234", Description: "This is an example local business.", }
Factory method usage:
localBusiness := schemaorg.NewLocalBusiness( "Example Business", &schemaorg.PostalAddress{StreetAddress: "123 Main St", AddressLocality: "Anytown", AddressRegion: "CA", PostalCode: "12345"}, "+1-800-555-1234", "This is an example local business", )
// Rendering JSON-LD using templ:
templ Page() { @localBusiness.ToJsonLd() }
// Rendering JSON-LD as `template.HTML` value:
jsonLdHtml := localBusiness.ToGoHTMLJsonLd()
Expected output:
{ "@context": "https://schema.org", "@type": "LocalBusiness", "name": "Example Business", "address": { "@type": "PostalAddress", "streetAddress": "123 Main St", "addressLocality": "Anytown", "addressRegion": "CA", "postalCode": "12345" }, "telephone": "+1-800-555-1234", "description": "This is an example local business" }
func NewLocalBusiness ¶
func NewLocalBusiness(name string, description string, url string, telephone string, logo *ImageObject, address *PostalAddress, openingHours []string, geo *GeoCoordinates, aggregateRating *AggregateRating, reviews []*Review) *LocalBusiness
NewLocalBusiness initializes a LocalBusiness with default context and type.
func (*LocalBusiness) ToGoHTMLJsonLd ¶
func (lb *LocalBusiness) ToGoHTMLJsonLd() (template.HTML, error)
ToGoHTMLJsonLd renders the LocalBusiness struct as `template.HTML` value for Go's `html/template`.
func (*LocalBusiness) ToJsonLd ¶
func (lb *LocalBusiness) ToJsonLd() templ.Component
ToJsonLd converts the LocalBusiness struct to a JSON-LD `templ.Component`.
type Offer ¶
type Offer struct { Type string `json:"@type"` URL string `json:"url,omitempty"` PriceCurrency string `json:"priceCurrency,omitempty"` Price string `json:"price,omitempty"` Availability string `json:"availability,omitempty"` ItemCondition string `json:"itemCondition,omitempty"` }
Offer represents a Schema.org Offer object
type Organization ¶
type Organization struct { Context string `json:"@context"` Type string `json:"@type"` Name string `json:"name,omitempty"` URL string `json:"url,omitempty"` Logo *ImageObject `json:"logo,omitempty"` ContactPoints []ContactPoint `json:"contactPoint,omitempty"` SameAs []string `json:"sameAs,omitempty"` }
Organization represents a Schema.org Organization object For more details about the meaning of the properties see: https://schema.org/Organization
func NewOrganization ¶
func NewOrganization(name string, url string, logoURL string, contactPoints []ContactPoint, sameAs []string) *Organization
NewOrganization initializes an Organization with default context and type.
func (*Organization) ToGoHTMLJsonLd ¶
func (org *Organization) ToGoHTMLJsonLd() (template.HTML, error)
ToGoHTMLJsonLd renders the Organization struct as `template.HTML` value for Go's `html/template`.
func (*Organization) ToJsonLd ¶
func (org *Organization) ToJsonLd() templ.Component
ToJsonLd converts the Organization struct to a JSON-LD `templ.Component`.
type Person ¶
type Person struct { Context string `json:"@context"` Type string `json:"@type"` Name string `json:"name,omitempty"` URL string `json:"url,omitempty"` Email string `json:"email,omitempty"` Image *ImageObject `json:"image,omitempty"` JobTitle string `json:"jobTitle,omitempty"` WorksFor *Organization `json:"worksFor,omitempty"` SameAs []string `json:"sameAs,omitempty"` Gender string `json:"gender,omitempty"` BirthDate string `json:"birthDate,omitempty"` Nationality string `json:"nationality,omitempty"` Telephone string `json:"telephone,omitempty"` Address *PostalAddress `json:"address,omitempty"` Affiliation *Organization `json:"affiliation,omitempty"` }
Person represents a Schema.org Person object For more details about the meaning of the properties see: https://schema.org/Person
func NewPerson ¶
func NewPerson(name string, url string, email string, image *ImageObject, jobTitle string, worksFor *Organization, sameAs []string, gender string, birthDate string, nationality string, telephone string, address *PostalAddress, affiliation *Organization) *Person
NewPerson initializes a Person with default context and type.
func (*Person) ToGoHTMLJsonLd ¶
ToGoHTMLJsonLd renders the Person struct as `template.HTML` value for Go's `html/template`.
type Place ¶
type Place struct { Context string `json:"@context"` Type string `json:"@type"` Name string `json:"name,omitempty"` Address *PostalAddress `json:"address,omitempty"` Geo *GeoCoordinates `json:"geo,omitempty"` }
Place represents a Schema.org Place object
type PostalAddress ¶
type PostalAddress struct { Type string `json:"@type"` StreetAddress string `json:"streetAddress,omitempty"` AddressLocality string `json:"addressLocality,omitempty"` AddressRegion string `json:"addressRegion,omitempty"` PostalCode string `json:"postalCode,omitempty"` AddressCountry string `json:"addressCountry,omitempty"` }
PostalAddress represents a Schema.org PostalAddress object
type Product ¶
type Product struct { Context string `json:"@context"` Type string `json:"@type"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Image []string `json:"image,omitempty"` SKU string `json:"sku,omitempty"` Brand *Brand `json:"brand,omitempty"` Offers *Offer `json:"offers,omitempty"` Category string `json:"category,omitempty"` AggregateRating *AggregateRating `json:"aggregateRating,omitempty"` Review []*Review `json:"review,omitempty"` }
Product represents a Schema.org Product object. For more details about the meaning of the properties see: https://schema.org/Product
Example usage:
Pure struct usage:
product := &schemaorg.Product{ Name: "Example Product", Description: "This is an example product description.", SKU: "12345", Brand: &schemaorg.Brand{Name: "Example Brand"}, Offers: &schemaorg.Offer{Price: "29.99", PriceCurrency: "USD"}, }
Factory method usage:
product := schemaorg.NewProduct( "Example Product", "This is an example product description.", "12345", &schemaorg.Brand{Name: "Example Brand"}, &schemaorg.Offer{Price: "29.99", PriceCurrency: "USD"}, )
// Rendering JSON-LD using templ:
templ Page() { @product.ToJsonLd() }
// Rendering JSON-LD as `template.HTML` value:
jsonLdHtml := product.ToGoHTMLJsonLd()
Expected output:
{ "@context": "https://schema.org", "@type": "Product", "name": "Example Product", "description": "This is an example product description", "sku": "12345", "brand": {"@type": "Brand", "name": "Example Brand"}, "offers": { "@type": "Offer", "price": "29.99", "priceCurrency": "USD" } }
func NewProduct ¶
func NewProduct(name, description string, image []string, sku string, brand *Brand, offers *Offer, category string, aggregateRating *AggregateRating, reviews []*Review) *Product
NewProduct initializes a Product with default context and type.
func (*Product) ToGoHTMLJsonLd ¶
ToGoHTMLJsonLd renders the Product struct as `template.HTML` value for Go's `html/template`.
type Question ¶
type Question struct { Type string `json:"@type"` Name string `json:"name,omitempty"` AcceptedAnswer *Answer `json:"acceptedAnswer,omitempty"` }
Question represents a Schema.org Question object
func NewQuestion ¶
NewQuestion initializes a Question with default type.
type Rating ¶
type Rating struct { Type string `json:"@type"` RatingValue float64 `json:"ratingValue,omitempty"` BestRating float64 `json:"bestRating,omitempty"` }
Rating represents a Schema.org Rating object
type Review ¶
type Review struct { Type string `json:"@type"` Author *Person `json:"author,omitempty"` DatePublished string `json:"datePublished,omitempty"` ReviewBody string `json:"reviewBody,omitempty"` ReviewRating *Rating `json:"reviewRating,omitempty"` }
Review represents a Schema.org Review object
type SiteNavigationElement ¶
type SiteNavigationElement struct {}
SiteNavigationElement represents a Schema.org SiteNavigationElement object. For more details about the meaning of the properties see: https://schema.org/SiteNavigationElement
Example usage:
Pure struct usage:
siteNavElement := &schemaorg.SiteNavigationElement{ Name: "Main Navigation", URL: "https://www.example.com", ItemList: &schemaorg.ItemList{ ItemListElement: []schemaorg.ItemListElement{ {Name: "Home", URL: "https://www.example.com", Position: 1}, {Name: "About", URL: "https://www.example.com/about", Position: 2}, }, }, }
Factory method usage:
siteNavElement := schemaorg.NewSiteNavigationElementWithItemList( "Main Navigation", "https://www.example.com", []schemaorg.ItemListElement{ {Name: "Home", URL: "https://www.example.com", Position: 1}, {Name: "About", URL: "https://www.example.com/about", Position: 2}, }, )
// Rendering JSON-LD using templ:
templ Page() { @siteNavElement.ToJsonLd() }
// Rendering JSON-LD as `template.HTML` value:
jsonLdHtml := siteNavElement.ToGoHTMLJsonLd()
Expected output:
{ "@context": "https://schema.org", "@type": "SiteNavigationElement", "name": "Main Navigation", "url": "https://www.example.com", "itemListElement": [ {"@type": "ListItem", "position": 1, "name": "Home", "url": "https://www.example.com"}, {"@type": "ListItem", "position": 2, "name": "About", "url": "https://www.example.com/about"} ] }
Example usage with `ToSitemapFile`:
// Generate a sitemap XML file siteNavElement := &schemaorg.SiteNavigationElement{ Name: "Main Navigation", URL: "https://www.example.com", ItemList: &schemaorg.ItemList{ ItemListElement: []schemaorg.ItemListElement{ {Name: "Home", URL: "https://www.example.com", Position: 1}, {Name: "About", URL: "https://www.example.com/about", Position: 2}, }, }, } err := siteNavElement.ToSitemapFile("statics/sitemap.xml") if err != nil { log.Fatalf("Failed to generate sitemap: %v", err) }
Example usage with `FromSitemapFile`:
// Parse a sitemap XML file and populate the SiteNavigationElement struct siteNavElement := &schemaorg.SiteNavigationElement{} err := siteNavElement.FromSitemapFile("statics/sitemap.xml") if err != nil { log.Fatalf("Failed to parse sitemap: %v", err) }
Expected output:
<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> <loc>http://www.example.com/</loc> <priority>0.5</priority> </url> <url> <loc>http://www.example.com/about</loc> <priority>0.5</priority> </url> </urlset>
func NewSiteNavigationElement ¶
func NewSiteNavigationElement(name string, url string, position int, identifier string, itemList *ItemList) *SiteNavigationElement
NewSiteNavigationElement initializes a SiteNavigationElement with default context and type.
func NewSiteNavigationElementWithItemList ¶
func NewSiteNavigationElementWithItemList(name, url string, items []ItemListElement) *SiteNavigationElement
NewSiteNavigationElementWithItemList initializes a SiteNavigationElement with default context, type, and an ItemList.
func (*SiteNavigationElement) FromSitemapFile ¶
func (s *SiteNavigationElement) FromSitemapFile(filename string) error
FromSitemapFile parses a sitemap XML file and populates the SiteNavigationElement struct.
func (*SiteNavigationElement) ToGoHTMLJsonLd ¶
func (sne *SiteNavigationElement) ToGoHTMLJsonLd() (template.HTML, error)
ToGoHTMLJsonLd renders the SiteNavigationElement struct as `template.HTML` value for Go's `html/template`.
func (*SiteNavigationElement) ToJsonLd ¶
func (sne *SiteNavigationElement) ToJsonLd() templ.Component
ToJsonLd converts the SiteNavigationElement struct to a JSON-LD `templ.Component`.
func (*SiteNavigationElement) ToSitemapFile ¶
func (s *SiteNavigationElement) ToSitemapFile(filename string) error
ToSitemapFile generates a sitemap XML file from the SiteNavigationElement struct.
type WebPage ¶
type WebPage struct { Context string `json:"@context"` Type string `json:"@type"` URL string `json:"url,omitempty"` Name string `json:"name,omitempty"` Headline string `json:"headline,omitempty"` Description string `json:"description,omitempty"` About string `json:"about,omitempty"` Keywords string `json:"keywords,omitempty"` InLanguage string `json:"inLanguage,omitempty"` IsPartOf string `json:"isPartOf,omitempty"` LastReviewed string `json:"lastReviewed,omitempty"` PrimaryImage string `json:"primaryImageOfPage,omitempty"` DatePublished string `json:"datePublished,omitempty"` DateModified string `json:"dateModified,omitempty"` }
WebPage represents a Schema.org WebPage object. For more details about the meaning of the properties see: https://schema.org/WebPage
Example usage:
Pure struct usage:
webpage := &schemaorg.WebPage{ URL: "https://www.example.com", Name: "Example WebPage", Headline: "Welcome to Example WebPage", Description: "This is an example webpage.", About: "Something related to the home page", Keywords: "example, webpage, demo", InLanguage: "en", }
Factory method usage:
webpage := schemaorg.NewWebPage( "https://www.example.com", "Example WebPage", "Welcome to Example WebPage", "This is an example webpage", "Something related to the home page", "example, webpage, demo", "en", "", "", "", "", "",
)
// Rendering JSON-LD using templ:
templ Page() { @webPage.ToJsonLd() }
// Rendering JSON-LD as `template.HTML` value:
jsonLdHtml := webPage.ToGoHTMLJsonLd()
Expected output:
{ "@context": "https://schema.org", "@type": "WebPage", "url": "https://www.example.com", "name": "Example WebPage", "headline": "Welcome to Example WebPage", "description": "This is an example webpage", "keywords": "example, webpage, demo" }
func NewWebPage ¶
func (*WebPage) ToGoHTMLJsonLd ¶
ToGoHTMLJsonLd renders the WebSite struct as `template.HTML` value for Go's `html/template`.
type WebSite ¶
type WebSite struct { Context string `json:"@context"` Type string `json:"@type"` URL string `json:"url,omitempty"` Name string `json:"name,omitempty"` AlternateName string `json:"alternateName,omitempty"` Description string `json:"description,omitempty"` PotentialAction *Action `json:"potentialAction,omitempty"` }
WebSite represents a Schema.org WebSite object
func NewWebSite ¶
func (*WebSite) ToGoHTMLJsonLd ¶
ToGoHTMLJsonLd renders the WebSite struct as `template.HTML` value for Go's `html/template`.
type XMLSitemap ¶
type XMLSitemap struct { XMLName xml.Name `xml:"urlset"` Xmlns string `xml:"xmlns,attr"` Urls []XMLSitemapUrl `xml:"url"` }
XMLSitemap represents the structure of a sitemap XML file.
type XMLSitemapUrl ¶
XMLSitemapUrl represents a single URL entry in the sitemap XML.