Documentation
¶
Index ¶
- func BuildURL(baseURL, path string) string
- func ExtractImageURL(tiptapJSON string) string
- func ExtractPlainText(tiptapJSON string) string
- func GetChangeFrequency(postType string) string
- func GetPriority(postType string) string
- func RenderAllSEOMetaTagsAsHTML(metaDescription string, og OpenGraphTags, tc TwitterCardTags) string
- func RenderMetaTags(tags []MetaTag) template.HTML
- func TruncateText(text string, maxLength int) string
- type ArticleStructuredData
- type ContentItem
- type JSONLDContext
- type JSONLDType
- type MetaTag
- type OpenGraphTags
- type Person
- type SitemapEntry
- type TipTapDocument
- type TipTapNode
- type TwitterCardTags
- type TwitterCardType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractImageURL ¶
ExtractImageURL finds the first image URL in TipTap JSON content
func ExtractPlainText ¶
ExtractPlainText extracts plain text from TipTap JSON content
func GetChangeFrequency ¶
func GetPriority ¶
func RenderAllSEOMetaTagsAsHTML ¶
func RenderAllSEOMetaTagsAsHTML(metaDescription string, og OpenGraphTags, tc TwitterCardTags) string
RenderAllSEOMetaTagsAsHTML renders all SEO meta tags as HTML
func RenderMetaTags ¶
RenderMetaTags renders multiple meta tags as HTML
func TruncateText ¶
TruncateText truncates text to a maximum length, adding ellipsis if needed
Types ¶
type ArticleStructuredData ¶
type ArticleStructuredData struct {
Context JSONLDContext `json:"@context"`
Type JSONLDType `json:"@type"`
Headline string `json:"headline"`
Description string `json:"description"`
Image string `json:"image,omitempty"`
DatePublished string `json:"datePublished"`
DateModified string `json:"dateModified"`
Author *Person `json:"author"`
Keywords string `json:"keywords,omitempty"`
}
ArticleStructuredData represents Schema.org Article structured data
func DefaultArticleStructuredData ¶
func DefaultArticleStructuredData(title, description, authorName string) ArticleStructuredData
DefaultArticleStructuredData generates Article structured data with defaults
func GenerateArticleStructuredData ¶
func GenerateArticleStructuredData(title, description, image, datePublished, dateModified, authorName string, tags []string) ArticleStructuredData
GenerateArticleStructuredData generates Article structured data from content metadata
func (ArticleStructuredData) ToJSON ¶
func (a ArticleStructuredData) ToJSON() (string, error)
ToJSON converts the structured data to JSON string
func (ArticleStructuredData) ToJSONLDScript ¶
func (a ArticleStructuredData) ToJSONLDScript() (string, error)
ToJSONLDScript renders the structured data as a JSON-LD script tag
type ContentItem ¶
type JSONLDContext ¶
type JSONLDContext string
JSONLDContext represents the JSON-LD context
const ( // JSONLDContextSchemaOrg is the Schema.org context JSONLDContextSchemaOrg JSONLDContext = "https://schema.org" )
type JSONLDType ¶
type JSONLDType string
JSONLDType represents the JSON-LD type
const ( // JSONLDTypeArticle is the Article type JSONLDTypeArticle JSONLDType = "Article" // JSONLDTypeBlogPosting is the BlogPosting type JSONLDTypeBlogPosting JSONLDType = "BlogPosting" // JSONLDTypeNewsArticle is the NewsArticle type JSONLDTypeNewsArticle JSONLDType = "NewsArticle" )
type MetaTag ¶
type MetaTag struct {
Name string
Property string
Content string
// contains filtered or unexported fields
}
MetaTag represents an HTML meta tag
func NewMetaTag ¶
NewMetaTag creates a new meta tag with name attribute
func NewPropertyMetaTag ¶
NewPropertyMetaTag creates a new meta tag with property attribute
func RenderAllSEOMetaTags ¶
func RenderAllSEOMetaTags(metaDescription string, og OpenGraphTags, tc TwitterCardTags) []MetaTag
RenderAllSEOMetaTags renders all SEO meta tags (description, Open Graph, Twitter Card)
type OpenGraphTags ¶
type OpenGraphTags struct {
Title string
Description string
Image string
URL string
Type string
SiteName string
}
OpenGraphTags represents Open Graph meta tags
func DefaultOpenGraphTags ¶
func DefaultOpenGraphTags() OpenGraphTags
DefaultOpenGraphTags returns default Open Graph tags
func (OpenGraphTags) ToMetaTags ¶
func (og OpenGraphTags) ToMetaTags() []MetaTag
ToMetaTags converts Open Graph tags to meta tags
type Person ¶
type Person struct {
Type string `json:"@type"`
Name string `json:"name"`
URL string `json:"url,omitempty"`
Email string `json:"email,omitempty"`
}
Person represents a person in Schema.org
type SitemapEntry ¶
func ContentToSitemapEntry ¶
func ContentToSitemapEntry(baseURL string, content ContentItem, postType string) SitemapEntry
func NewHomepageEntry ¶
func NewHomepageEntry(baseURL string) SitemapEntry
type TipTapDocument ¶
type TipTapDocument struct {
Type string `json:"type"`
Content []TipTapNode `json:"content"`
}
TipTapDocument represents a TipTap JSON document
type TipTapNode ¶
type TipTapNode struct {
Type string `json:"type"`
Attrs map[string]any `json:"attrs,omitempty"`
Content []TipTapNode `json:"content,omitempty"`
Text string `json:"text,omitempty"`
}
TipTapNode represents a node in TipTap JSON
type TwitterCardTags ¶
type TwitterCardTags struct {
Card TwitterCardType
Title string
Description string
Image string
}
TwitterCardTags represents Twitter Card meta tags
func DefaultTwitterCardTags ¶
func DefaultTwitterCardTags() TwitterCardTags
DefaultTwitterCardTags returns default Twitter Card tags
func (TwitterCardTags) ToMetaTags ¶
func (tc TwitterCardTags) ToMetaTags() []MetaTag
ToMetaTags converts Twitter Card tags to meta tags
type TwitterCardType ¶
type TwitterCardType string
TwitterCardType represents Twitter card types
const ( // TwitterCardSummary is the summary card type TwitterCardSummary TwitterCardType = "summary" // TwitterCardSummaryLargeImage is the summary card with large image type TwitterCardSummaryLargeImage TwitterCardType = "summary_large_image" )