sitemap

package module
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

README

Sitemap Format

Coverage godoc Go Report Card Codacy Badge

Simple sitemap formatting, with a little syntactic sugar.

Installation

go get github.com/mingard/sitemap-format

Usage

Creating a basic Sitemap
package main

import sitemap "github.com/mingard/sitemap-format"

func main() {
  xml := sitemap.New()

  loc := sitemap.NewLoc()
  loc.SetLocation("https://domain.com")
  xml.Add(loc)

  out, _ := xml.OutputString()
  fmt.Println(out)
}

// Output: <?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url><loc>https://domain.com</loc><lastmod>2022-11-03T11:56:00.26065Z</lastmod></url></urlset>

Documentation

Index

Examples

Constants

View Source
const (
	// TagLimit is the number of permitted video tags.
	TagLimit = 32
	// MaxDescriptionLength is the maximum length of the video:description.
	MaxDescriptionLength = 2048
	// DurationMin is the minimum video duration of 1 second.
	DurationMin int = 1
	// DurationMax is the maximum video duration length in seconds (8 hours).
	DurationMax int = 28800
	// RatingLow is the lowest posible rating.
	RatingLow float32 = 0.0
	// RatingHigh is the highest posible rating.
	RatingHigh float32 = 5.0
)

Variables

View Source
var (
	// Allow is the allow attribute.
	Allow = &xml.Attr{
		Name:  xml.Name{Local: "relationship"},
		Value: "allow",
	}
	// Deny is the deny attribute.
	Deny = &xml.Attr{
		Name:  xml.Name{Local: "relationship"},
		Value: "deny",
	}
)
View Source
var (
	// XMLNSDefault is the default XML Namespace type.
	XMLNSDefault = &xml.Attr{
		Name:  xml.Name{Local: "xmlns"},
		Value: "http://www.sitemaps.org/schemas/sitemap/0.9",
	}
	// XMLNSNews is the XML Namespace type for news.
	XMLNSNews = &xml.Attr{
		Name:  xml.Name{Local: "xmlns:news"},
		Value: "http://www.google.com/schemas/sitemap-news/0.9",
	}
	// XMLNSXHTML is the XML Namespace type for XHTML.
	XMLNSXHTML = &xml.Attr{
		Name:  xml.Name{Local: "xmlns"},
		Value: "http://www.w3.org/1999/xhtml",
	}
	// XMLNSMobile is the XML Namespace type for mobile-only content.
	XMLNSMobile = &xml.Attr{
		Name:  xml.Name{Local: "xmlns:mobile"},
		Value: "http://www.google.com/schemas/sitemap-mobile/1.0",
	}
	// XMLNSImage is the XML Namespace type for images.
	XMLNSImage = &xml.Attr{
		Name:  xml.Name{Local: "xmlns:image"},
		Value: "http://www.google.com/schemas/sitemap-image/1.1",
	}
	// XMLNSVideo is the XML Namespace type for videos.
	XMLNSVideo = &xml.Attr{
		Name:  xml.Name{Local: "xmlns:video"},
		Value: "http://www.google.com/schemas/sitemap-video/1.1",
	}
)

Functions

func Date added in v1.3.2

func Date(t time.Time) customDate

Date returns a new short format date.

func DateFull added in v1.3.2

func DateFull(t time.Time) customDate

DateFull returns a long format date.

Types

type BoolStr

type BoolStr string

BoolStr is a string representation of a boolean.

const (
	// Yes is a truthy string representation.
	Yes BoolStr = "yes"
	// No is a falsy string representation.
	No BoolStr = "no"
)

type Image

type Image struct {
	XMLName xml.Name `xml:"image:image"`
	// Loc is the location of the image
	Loc string `xml:"image:loc"`
}

Image stores image entry data.

func NewImage

func NewImage() *Image

NewImage returns a new instance of the default Image extension.

func (*Image) SetLocation added in v1.2.2

func (i *Image) SetLocation(l string) *Image

SetLocation sets the image location.

type Lang

type Lang string

Lang is a string representation of a two character language string.

const (
	// LangDefault is set to 'en'.
	LangDefault Lang = LanguageEN
	// LanguageAA is a string language key.
	LanguageAA Lang = "aa"
	// LanguageAB is a string language key.
	LanguageAB Lang = "ab"
	// LanguageAE is a string language key.
	LanguageAE Lang = "ae"
	// LanguageAF is a string language key.
	LanguageAF Lang = "af"
	// LanguageAK is a string language key.
	LanguageAK Lang = "ak"
	// LanguageAM is a string language key.
	LanguageAM Lang = "am"
	// LanguageAN is a string language key.
	LanguageAN Lang = "an"
	// LanguageAR is a string language key.
	LanguageAR Lang = "ar"
	// LanguageAS is a string language key.
	LanguageAS Lang = "as"
	// LanguageAV is a string language key.
	LanguageAV Lang = "av"
	// LanguageAY is a string language key.
	LanguageAY Lang = "ay"
	// LanguageAZ is a string language key.
	LanguageAZ Lang = "az"
	// LanguageBA is a string language key.
	LanguageBA Lang = "ba"
	// LanguageBE is a string language key.
	LanguageBE Lang = "be"
	// LanguageBG is a string language key.
	LanguageBG Lang = "bg"
	// LanguageBH is a string language key.
	LanguageBH Lang = "bh"
	// LanguageBI is a string language key.
	LanguageBI Lang = "bi"
	// LanguageBM is a string language key.
	LanguageBM Lang = "bm"
	// LanguageBN is a string language key.
	LanguageBN Lang = "bn"
	// LanguageBO is a string language key.
	LanguageBO Lang = "bo"
	// LanguageBR is a string language key.
	LanguageBR Lang = "br"
	// LanguageBS is a string language key.
	LanguageBS Lang = "bs"
	// LanguageCA is a string language key.
	LanguageCA Lang = "ca"
	// LanguageCE is a string language key.
	LanguageCE Lang = "ce"
	// LanguageCH is a string language key.
	LanguageCH Lang = "ch"
	// LanguageCO is a string language key.
	LanguageCO Lang = "co"
	// LanguageCR is a string language key.
	LanguageCR Lang = "cr"
	// LanguageCS is a string language key.
	LanguageCS Lang = "cs"
	// LanguageCU is a string language key.
	LanguageCU Lang = "cu"
	// LanguageCV is a string language key.
	LanguageCV Lang = "cv"
	// LanguageCY is a string language key.
	LanguageCY Lang = "cy"
	// LanguageDA is a string language key.
	LanguageDA Lang = "da"
	// LanguageDE is a string language key.
	LanguageDE Lang = "de"
	// LanguageDV is a string language key.
	LanguageDV Lang = "dv"
	// LanguageDZ is a string language key.
	LanguageDZ Lang = "dz"
	// LanguageEE is a string language key.
	LanguageEE Lang = "ee"
	// LanguageEL is a string language key.
	LanguageEL Lang = "el"
	// LanguageEN is a string language key.
	LanguageEN Lang = "en"
	// LanguageEO is a string language key.
	LanguageEO Lang = "eo"
	// LanguageES is a string language key.
	LanguageES Lang = "es"
	// LanguageET is a string language key.
	LanguageET Lang = "et"
	// LanguageEU is a string language key.
	LanguageEU Lang = "eu"
	// LanguageFA is a string language key.
	LanguageFA Lang = "fa"
	// LanguageFF is a string language key.
	LanguageFF Lang = "ff"
	// LanguageFI is a string language key.
	LanguageFI Lang = "fi"
	// LanguageFJ is a string language key.
	LanguageFJ Lang = "fj"
	// LanguageFO is a string language key.
	LanguageFO Lang = "fo"
	// LanguageFR is a string language key.
	LanguageFR Lang = "fr"
	// LanguageFY is a string language key.
	LanguageFY Lang = "fy"
	// LanguageGA is a string language key.
	LanguageGA Lang = "ga"
	// LanguageGD is a string language key.
	LanguageGD Lang = "gd"
	// LanguageGL is a string language key.
	LanguageGL Lang = "gl"
	// LanguageGN is a string language key.
	LanguageGN Lang = "gn"
	// LanguageGU is a string language key.
	LanguageGU Lang = "gu"
	// LanguageGV is a string language key.
	LanguageGV Lang = "gv"
	// LanguageHA is a string language key.
	LanguageHA Lang = "ha"
	// LanguageHE is a string language key.
	LanguageHE Lang = "he"
	// LanguageHI is a string language key.
	LanguageHI Lang = "hi"
	// LanguageHO is a string language key.
	LanguageHO Lang = "ho"
	// LanguageHR is a string language key.
	LanguageHR Lang = "hr"
	// LanguageHT is a string language key.
	LanguageHT Lang = "ht"
	// LanguageHU is a string language key.
	LanguageHU Lang = "hu"
	// LanguageHY is a string language key.
	LanguageHY Lang = "hy"
	// LanguageHZ is a string language key.
	LanguageHZ Lang = "hz"
	// LanguageIA is a string language key.
	LanguageIA Lang = "ia"
	// LanguageID is a string language key.
	LanguageID Lang = "id"
	// LanguageIE is a string language key.
	LanguageIE Lang = "ie"
	// LanguageIG is a string language key.
	LanguageIG Lang = "ig"
	// LanguageII is a string language key.
	LanguageII Lang = "ii"
	// LanguageIK is a string language key.
	LanguageIK Lang = "ik"
	// LanguageIO is a string language key.
	LanguageIO Lang = "io"
	// LanguageIS is a string language key.
	LanguageIS Lang = "is"
	// LanguageIT is a string language key.
	LanguageIT Lang = "it"
	// LanguageIU is a string language key.
	LanguageIU Lang = "iu"
	// LanguageJA is a string language key.
	LanguageJA Lang = "ja"
	// LanguageJV is a string language key.
	LanguageJV Lang = "jv"
	// LanguageKA is a string language key.
	LanguageKA Lang = "ka"
	// LanguageKG is a string language key.
	LanguageKG Lang = "kg"
	// LanguageKI is a string language key.
	LanguageKI Lang = "ki"
	// LanguageKJ is a string language key.
	LanguageKJ Lang = "kj"
	// LanguageKK is a string language key.
	LanguageKK Lang = "kk"
	// LanguageKL is a string language key.
	LanguageKL Lang = "kl"
	// LanguageKM is a string language key.
	LanguageKM Lang = "km"
	// LanguageKN is a string language key.
	LanguageKN Lang = "kn"
	// LanguageKO is a string language key.
	LanguageKO Lang = "ko"
	// LanguageKR is a string language key.
	LanguageKR Lang = "kr"
	// LanguageKS is a string language key.
	LanguageKS Lang = "ks"
	// LanguageKU is a string language key.
	LanguageKU Lang = "ku"
	// LanguageKV is a string language key.
	LanguageKV Lang = "kv"
	// LanguageKW is a string language key.
	LanguageKW Lang = "kw"
	// LanguageKY is a string language key.
	LanguageKY Lang = "ky"
	// LanguageLA is a string language key.
	LanguageLA Lang = "la"
	// LanguageLB is a string language key.
	LanguageLB Lang = "lb"
	// LanguageLG is a string language key.
	LanguageLG Lang = "lg"
	// LanguageLI is a string language key.
	LanguageLI Lang = "li"
	// LanguageLN is a string language key.
	LanguageLN Lang = "ln"
	// LanguageLO is a string language key.
	LanguageLO Lang = "lo"
	// LanguageLT is a string language key.
	LanguageLT Lang = "lt"
	// LanguageLU is a string language key.
	LanguageLU Lang = "lu"
	// LanguageLV is a string language key.
	LanguageLV Lang = "lv"
	// LanguageMG is a string language key.
	LanguageMG Lang = "mg"
	// LanguageMH is a string language key.
	LanguageMH Lang = "mh"
	// LanguageMI is a string language key.
	LanguageMI Lang = "mi"
	// LanguageMK is a string language key.
	LanguageMK Lang = "mk"
	// LanguageML is a string language key.
	LanguageML Lang = "ml"
	// LanguageMN is a string language key.
	LanguageMN Lang = "mn"
	// LanguageMR is a string language key.
	LanguageMR Lang = "mr"
	// LanguageMS is a string language key.
	LanguageMS Lang = "ms"
	// LanguageMT is a string language key.
	LanguageMT Lang = "mt"
	// LanguageMY is a string language key.
	LanguageMY Lang = "my"
	// LanguageNA is a string language key.
	LanguageNA Lang = "na"
	// LanguageNB is a string language key.
	LanguageNB Lang = "nb"
	// LanguageND is a string language key.
	LanguageND Lang = "nd"
	// LanguageNE is a string language key.
	LanguageNE Lang = "ne"
	// LanguageNG is a string language key.
	LanguageNG Lang = "ng"
	// LanguageNL is a string language key.
	LanguageNL Lang = "nl"
	// LanguageNN is a string language key.
	LanguageNN Lang = "nn"
	// LanguageNO is a string language key.
	LanguageNO Lang = "no"
	// LanguageNR is a string language key.
	LanguageNR Lang = "nr"
	// LanguageNV is a string language key.
	LanguageNV Lang = "nv"
	// LanguageNY is a string language key.
	LanguageNY Lang = "ny"
	// LanguageOC is a string language key.
	LanguageOC Lang = "oc"
	// LanguageOJ is a string language key.
	LanguageOJ Lang = "oj"
	// LanguageOM is a string language key.
	LanguageOM Lang = "om"
	// LanguageOR is a string language key.
	LanguageOR Lang = "or"
	// LanguageOS is a string language key.
	LanguageOS Lang = "os"
	// LanguagePA is a string language key.
	LanguagePA Lang = "pa"
	// LanguagePI is a string language key.
	LanguagePI Lang = "pi"
	// LanguagePL is a string language key.
	LanguagePL Lang = "pl"
	// LanguagePS is a string language key.
	LanguagePS Lang = "ps"
	// LanguagePT is a string language key.
	LanguagePT Lang = "pt"
	// LanguageQU is a string language key.
	LanguageQU Lang = "qu"
	// LanguageRM is a string language key.
	LanguageRM Lang = "rm"
	// LanguageRN is a string language key.
	LanguageRN Lang = "rn"
	// LanguageRO is a string language key.
	LanguageRO Lang = "ro"
	// LanguageRU is a string language key.
	LanguageRU Lang = "ru"
	// LanguageRW is a string language key.
	LanguageRW Lang = "rw"
	// LanguageSA is a string language key.
	LanguageSA Lang = "sa"
	// LanguageSC is a string language key.
	LanguageSC Lang = "sc"
	// LanguageSD is a string language key.
	LanguageSD Lang = "sd"
	// LanguageSE is a string language key.
	LanguageSE Lang = "se"
	// LanguageSG is a string language key.
	LanguageSG Lang = "sg"
	// LanguageSI is a string language key.
	LanguageSI Lang = "si"
	// LanguageSK is a string language key.
	LanguageSK Lang = "sk"
	// LanguageSL is a string language key.
	LanguageSL Lang = "sl"
	// LanguageSM is a string language key.
	LanguageSM Lang = "sm"
	// LanguageSN is a string language key.
	LanguageSN Lang = "sn"
	// LanguageSO is a string language key.
	LanguageSO Lang = "so"
	// LanguageSQ is a string language key.
	LanguageSQ Lang = "sq"
	// LanguageSR is a string language key.
	LanguageSR Lang = "sr"
	// LanguageSS is a string language key.
	LanguageSS Lang = "ss"
	// LanguageST is a string language key.
	LanguageST Lang = "st"
	// LanguageSU is a string language key.
	LanguageSU Lang = "su"
	// LanguageSV is a string language key.
	LanguageSV Lang = "sv"
	// LanguageSW is a string language key.
	LanguageSW Lang = "sw"
	// LanguageTA is a string language key.
	LanguageTA Lang = "ta"
	// LanguageTE is a string language key.
	LanguageTE Lang = "te"
	// LanguageTG is a string language key.
	LanguageTG Lang = "tg"
	// LanguageTH is a string language key.
	LanguageTH Lang = "th"
	// LanguageTI is a string language key.
	LanguageTI Lang = "ti"
	// LanguageTK is a string language key.
	LanguageTK Lang = "tk"
	// LanguageTL is a string language key.
	LanguageTL Lang = "tl"
	// LanguageTN is a string language key.
	LanguageTN Lang = "tn"
	// LanguageTO is a string language key.
	LanguageTO Lang = "to"
	// LanguageTR is a string language key.
	LanguageTR Lang = "tr"
	// LanguageTS is a string language key.
	LanguageTS Lang = "ts"
	// LanguageTT is a string language key.
	LanguageTT Lang = "tt"
	// LanguageTW is a string language key.
	LanguageTW Lang = "tw"
	// LanguageTY is a string language key.
	LanguageTY Lang = "ty"
	// LanguageUG is a string language key.
	LanguageUG Lang = "ug"
	// LanguageUK is a string language key.
	LanguageUK Lang = "uk"
	// LanguageUR is a string language key.
	LanguageUR Lang = "ur"
	// LanguageUZ is a string language key.
	LanguageUZ Lang = "uz"
	// LanguageVE is a string language key.
	LanguageVE Lang = "ve"
	// LanguageVI is a string language key.
	LanguageVI Lang = "vi"
	// LanguageVO is a string language key.
	LanguageVO Lang = "vo"
	// LanguageWA is a string language key.
	LanguageWA Lang = "wa"
	// LanguageWO is a string language key.
	LanguageWO Lang = "wo"
	// LanguageXH is a string language key.
	LanguageXH Lang = "xh"
	// LanguageYI is a string language key.
	LanguageYI Lang = "yi"
	// LanguageYO is a string language key.
	LanguageYO Lang = "yo"
	// LanguageZA is a string language key.
	LanguageZA Lang = "za"
	// LanguageZH is a string language key.
	LanguageZH Lang = "zh"
	// LanguageZU is a string language key.
	LanguageZU Lang = "zu"
)

func Language added in v1.3.3

func Language(s string) Lang

Language returns either a valid language or a default.

type Location added in v1.2.2

type Location struct {
	XMLName          xml.Name   `xml:"url,omitempty"`
	Location         string     `xml:"loc,omitempty"`
	ChangeFrequency  string     `xml:"changefreq,omitempty"`
	Priority         string     `xml:"priority,omitempty"`
	LastModifiedDate customDate `xml:"lastmod,omitempty"`
	News             *News      `xml:"news:news,omitempty"`
	Images           []*Image   `xml:"image:image,omitempty"`
	Videos           []*Video   `xml:"video:video,omitempty"`
}

Location is a location block to be nested under the parent node.

func NewLoc added in v1.2.2

func NewLoc() *Location

NewLoc returns a new instance of the default loc.

func (*Location) AddImage added in v1.2.2

func (l *Location) AddImage(i ...*Image)

AddImage adds an image sub-node.

func (*Location) AddVideo added in v1.2.2

func (l *Location) AddVideo(v ...*Video)

AddVideo adds an video sub-node.

func (*Location) SetLastModified added in v1.2.2

func (l *Location) SetLastModified(c customDate)

SetLastModified sets the value of the modified date field.

func (*Location) SetLocation added in v1.2.2

func (l *Location) SetLocation(loc string)

SetLocation sets the url's location parameter.

func (*Location) SetNews added in v1.2.2

func (l *Location) SetNews(n *News)

SetNews sets the single news sub-node.

type News

type News struct {
	XMLName         xml.Name     `xml:"news:news"`
	Publication     *Publication `xml:"news:publication"`
	PublicationDate customDate   `xml:"news:publication_date"`
	Title           string       `xml:"news:title"`
}

News stores news entry data.

func NewNews

func NewNews() *News

NewNews returns a new instance of the default News extension.

func (*News) SetLanguage

func (n *News) SetLanguage(l Lang) *News

SetLanguage sets the news extensions Publication.NewsLanguage parameter. Must be Lang.

func (*News) SetName added in v1.0.1

func (n *News) SetName(na string) *News

SetName sets the news extensions publication name parameter.

func (*News) SetPublicationDate

func (n *News) SetPublicationDate(c customDate) *News

SetPublicationDate sets the news extensions PublicationDate parameter.

func (*News) SetTitle

func (n *News) SetTitle(t string) *News

SetTitle sets the news extensions title parameter.

type Platform

type Platform struct {
	XMLName      xml.Name  `xml:"video:platform,omitempty"`
	Relationship *xml.Attr `xml:",attr,omitempty"`
	Value        string    `xml:",chardata"`
}

Platform stores allowed and restricted platforms.

type PlatformName

type PlatformName string

PlatformName is a string name for a platform.

const (
	// Web is the string key for the web platform.
	Web PlatformName = "web"
	// Mobile is the string key for the mobile platform.
	Mobile PlatformName = "mobile"
	// TV is the string key for the tv platform.
	TV PlatformName = "tv"
)

type Publication

type Publication struct {
	XMLName      xml.Name `xml:"news:publication"`
	Name         string   `xml:"news:name,omitempty"`
	NewsLanguage Lang     `xml:"news:language,omitempty"`
}

Publication is the news publication sub-component to News.

type Restriction

type Restriction struct {
	XMLName      xml.Name  `xml:"video:restriction,omitempty"`
	Relationship *xml.Attr `xml:",attr,omitempty"`
	Value        string    `xml:",chardata"`
}

Restriction stores country restriction details

type Uploader

type Uploader struct {
	XMLName xml.Name `xml:"video:uploader,omitempty"`
	// Info (optional) specifies the URL of a webpage with additional information about this uploader.
	Info string `xml:"info,attr,omitempty"`
	// Value is the video uploader's name, a string with a maximum of 255 characters.
	Value string `xml:",chardata"`
}

Uploader stores the uploader of the video.

type Video

type Video struct {
	XMLName xml.Name `xml:"video:video"`

	// Title HTML entities must be escaped or wrapped in a CDATA block.
	Title string `xml:"video:title"`
	// Description Maximum {{MaxDescriptionLength}} characters. All HTML entities must be escaped or wrapped in a CDATA block. It must match the description displayed on the web page (it doesn't need to be a word-for-word match).
	Description  string `xml:"video:description,omitempty"`
	ThumbnailLoc string `xml:"video:thumbnail_loc,omitempty"`
	// ContentLoc HTML and Flash aren't supported formats.
	ContentLoc string `xml:"video:content_loc,omitempty"`
	// Can be used instead of or alongside ContentLoc.
	PlayerLoc string `xml:"video:player_loc,omitempty"`

	// Duration value must be from {{DurationMin}} to {{DurationMax}} inclusive.
	Duration int `xml:"video:duration,omitempty"`
	// ExpirationDate format either YYYY-MM-DD or YYYY-MM-DDThh:mm:ss+TZD
	ExpirationDate customDate `xml:"video:expiration_date,omitempty"`

	// Rating values are float numbers in the range {{RatingLow}} (low) to {{RatingHigh}} (high), inclusive.
	Rating          float32    `xml:"video:rating,omitempty"`
	ViewCount       int        `xml:"video:view_count,omitempty"`
	PublicationDate customDate `xml:"video:publication_date,omitempty"`
	// FamilyFriendly whether the video is available with SafeSearch.
	FamilyFriendly BoolStr        `xml:"video:family_friendly,omitempty"`
	Restrictions   []*Restriction `xml:"video:restriction,omitempty"`
	Platforms      []*Platform    `xml:"video:platform,omitempty"`
	// RequiresSubscription indicates whether a subscription is required to view the video.
	RequiresSubscription BoolStr   `xml:"video:requires_subscription,omitempty"`
	Uploader             *Uploader `xml:"video:uploader,omitempty"`
	// Live indicates whether the video is a live stream
	Live BoolStr `xml:"video:live,omitempty"`
	// Tags are limited to a max of {{TagLimit}}.
	Tags []string `xml:"video:tag,omitempty"`
}

Video stores video entry data.

func NewVideo

func NewVideo() *Video

NewVideo returns a new instance of the default Video extension.

func (*Video) AllowCountries

func (v *Video) AllowCountries(c string) *Video

AllowCountries creates a list of allowed countries.

func (*Video) AllowPlatforms

func (v *Video) AllowPlatforms(p ...PlatformName) *Video

AllowPlatforms creates a list of allowed platforms.

func (*Video) DenyCountries

func (v *Video) DenyCountries(c string) *Video

DenyCountries creates a list of denied countries.

func (*Video) DenyPlatforms

func (v *Video) DenyPlatforms(p ...PlatformName) *Video

DenyPlatforms creates a list of denied platforms.

func (*Video) IsFamilyFriendly

func (v *Video) IsFamilyFriendly() *Video

IsFamilyFriendly sets the family friendly option to 'yes'

func (*Video) IsLive

func (v *Video) IsLive() *Video

IsLive sets the live option to 'yes'

func (*Video) NotFamilyFriendly

func (v *Video) NotFamilyFriendly() *Video

NotFamilyFriendly sets the family friendly option to 'no'

func (*Video) NotLive

func (v *Video) NotLive() *Video

NotLive sets the live option to 'no'

func (*Video) SetContentLocation added in v1.2.2

func (v *Video) SetContentLocation(c string) *Video

SetContentLocation sets the video content location parameter.

func (*Video) SetDescription

func (v *Video) SetDescription(d string) *Video

SetDescription sets the video extensions description parameter.

func (*Video) SetDuration

func (v *Video) SetDuration(d int) *Video

SetDuration sets the video duration parameter.

func (*Video) SetExpirationDate

func (v *Video) SetExpirationDate(c customDate) *Video

SetExpirationDate sets the video ExpirationDate parameter.

func (*Video) SetPlayerLocation added in v1.2.2

func (v *Video) SetPlayerLocation(p string) *Video

SetPlayerLocation sets the video player location parameter.

func (*Video) SetPublicationDate

func (v *Video) SetPublicationDate(c customDate) *Video

SetPublicationDate sets the video extensions PublicationDate parameter.

func (*Video) SetRating

func (v *Video) SetRating(r float32) *Video

SetRating sets the video rating.

func (*Video) SetTags

func (v *Video) SetTags(t ...string) *Video

SetTags sets tag values

func (*Video) SetThumbnailLocation added in v1.2.2

func (v *Video) SetThumbnailLocation(t string) *Video

SetThumbnailLocation sets the video thumbnail location parameter.

func (*Video) SetTitle

func (v *Video) SetTitle(t string) *Video

SetTitle sets the video extensions title parameter.

func (*Video) SetUploaderInfo

func (v *Video) SetUploaderInfo(i string) *Video

SetUploaderInfo sets the uploader

func (*Video) SetUploaderVal

func (v *Video) SetUploaderVal(val string) *Video

SetUploaderVal sets the uploader value

func (*Video) SetViewCount

func (v *Video) SetViewCount(vc int) *Video

SetViewCount sets the video view_count.

func (*Video) SubNotRequired

func (v *Video) SubNotRequired() *Video

SubNotRequired sets the requires_subscription option to 'no'

func (*Video) SubRequired

func (v *Video) SubRequired() *Video

SubRequired sets the requires_subscription option to 'yes'

type XML added in v1.2.0

type XML struct {
	// contains filtered or unexported fields
}

XML is the top level XML node for the sitemap

func New

func New() *XML

New returns a new instance of the default XML.

Example
xml := New()

out, _ := xml.Output()
fmt.Println(string(out))
Output:

<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>

func NewSitemapIndex added in v1.1.0

func NewSitemapIndex() *XML

NewSitemapIndex creates a new sitemap with a sitemap_index child node.

func (*XML) Add added in v1.2.2

func (x *XML) Add(l *Location)

Add inserts an entry into the XML's first parent node.

func (*XML) Output added in v1.2.0

func (x *XML) Output() ([]byte, error)

Output returns the output value as bytes

func (*XML) OutputPrettyString added in v1.2.0

func (x *XML) OutputPrettyString(prefix, indent string) (string, error)

OutputPrettyString returns the output as a string with prettified rules. Empty if there's an error.

Example
xml := New()

out, _ := xml.OutputPrettyString("", "  ")
fmt.Println(out)
Output:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>

func (*XML) OutputString added in v1.2.0

func (x *XML) OutputString() (string, error)

OutputString returns the output as a string. Empty if there's an error.

Example
xml := New()

out, _ := xml.OutputString()
fmt.Println(out)
Output:

<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>

func (*XML) PrettyFormat added in v1.2.0

func (x *XML) PrettyFormat(prefix, indent string)

PrettyFormat sets preferences for the prettified output.

Jump to

Keyboard shortcuts

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