seo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildURL

func BuildURL(baseURL, path string) string

BuildURL constructs a full URL from path

func ExtractImageURL

func ExtractImageURL(tiptapJSON string) string

ExtractImageURL finds the first image URL in TipTap JSON content

func ExtractPlainText

func ExtractPlainText(tiptapJSON string) string

ExtractPlainText extracts plain text from TipTap JSON content

func GetChangeFrequency

func GetChangeFrequency(postType string) string

func GetPriority

func GetPriority(postType string) string

func RenderAllSEOMetaTagsAsHTML

func RenderAllSEOMetaTagsAsHTML(metaDescription string, og OpenGraphTags, tc TwitterCardTags) string

RenderAllSEOMetaTagsAsHTML renders all SEO meta tags as HTML

func RenderMetaTags

func RenderMetaTags(tags []MetaTag) template.HTML

RenderMetaTags renders multiple meta tags as HTML

func TruncateText

func TruncateText(text string, maxLength int) string

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 ContentItem struct {
	Slug      string
	UpdatedAt string
}

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

func NewMetaTag(name, content string) MetaTag

NewMetaTag creates a new meta tag with name attribute

func NewPropertyMetaTag

func NewPropertyMetaTag(property, content string) MetaTag

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)

func (MetaTag) Render

func (m MetaTag) Render() template.HTML

Render renders a meta tag as HTML

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

func NewPerson

func NewPerson(name string) *Person

NewPerson creates a new Person

type SitemapEntry

type SitemapEntry struct {
	Loc        string
	LastMod    string
	ChangeFreq string
	Priority   string
}

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"
)

Jump to

Keyboard shortcuts

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