pages

package module
v0.0.0-...-20fdfd3 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: MIT Imports: 27 Imported by: 0

README

Pages

Go Reference Go Report Card codecov License

A comprehensive Go package for content management that provides multi-site support, and flexible page routing.

Features

  • 🌐 Multi-Site Support - Manage multiple websites with different domains, locales, and countries
  • 📝 Flexible Page Types - CMS pages, hybrid routing with dynamic patterns, and internal system pages
  • 🧪 Comprehensive Testing - Extensive test coverage with mock implementations

Installation

go get github.com/gowool/pages

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

View Source
const (
	HeaderXPageDecorable    = "X-Page-Decorable"
	HeaderXPageNotDecorable = "X-Page-Not-Decorable"
)
View Source
const (
	PageCMS               = "_page_cms"
	PageAliasPrefix       = "_page_alias_"
	PageInternalPrefix    = "_page_internal_"
	PageInternalCreate    = PageInternalPrefix + "create"
	PageErrorPrefix       = PageInternalPrefix + "error_"
	PageErrorUnauthorized = PageErrorPrefix + "401"
	PageErrorForbidden    = PageErrorPrefix + "403"
	PageErrorNotFound     = PageErrorPrefix + "404"
	PageError4xx          = PageErrorPrefix + "4xx"
	PageError5xx          = PageErrorPrefix + "5xx"

	PageCMSPattern    = "/{_page_cms...}"
	HomeHybridPattern = "/{$}"
)
View Source
const (
	LinkRelAlternate  = "alternate"
	LinkRelAuthor     = "author"
	LinkRelCanonical  = "canonical"
	LinkRelLicense    = "license"
	LinkRelNext       = "next"
	LinkRelPrev       = "prev"
	LinkRelStylesheet = "stylesheet"
	LinkRelIcon       = "icon"
)
View Source
const (
	ReferrerPolicyNoReferrer              = "no-referrer"
	ReferrerPolicyNoReferrerWhenDowngrade = "no-referrer-when-downgrade"
	ReferrerPolicyOrigin                  = "origin"
	ReferrerPolicyOriginWhenCrossOrigin   = "origin-when-cross-origin"
	ReferrerPolicySameOrigin              = "same-origin"
	ReferrerPolicyStrictOrigin            = "strict-origin"
	ReferrerPolicyUnsafeUrl               = "unsafe-url"
)
View Source
const DefaultCharset = "UTF-8"

Variables

View Source
var (
	ErrSiteNotFound    = errors.New("site not found")
	ErrPageNotFound    = errors.New("page not found")
	ErrPrivatePage     = errors.New("page is private")
	ErrUniqueViolation = errors.New("unique violation")
)
View Source
var DefaultPageDecoratorStrategy = &NoopPageDecoratorStrategy{}
View Source
var ErrThemeRequired = errors.New("theme required")
View Source
var SEOFuncMap = template.FuncMap{
	"strip_tags":        stripTags,
	"escape_double_q":   escapeDoubleQuotes,
	"reverse_title_tag": reverseTitleTag,
	"title_tag":         titleTag,
	"meta_tags":         metaTags,
	"html_attrs":        htmlAttrs,
	"head_attrs":        headAttrs,
	"body_attrs":        bodyAttrs,
	"lang_alternates":   langAlternates,
	"head_links":        headLinks,
}

Functions

func ErrorMapper

func ErrorMapper(err error) *wo.HTTPError

func ErrorRenderer

func ErrorRenderer[T Resolver](
	handler func(e T) error,
	manager PageManager,
	strategy PageDecoratorStrategy,
	authorizer PageAuthorizer[T],
	patternFinder ErrorPatternFinderFunc,
	logger *slog.Logger,
	skippers ...middleware.Skipper[T],
) func(T, *wo.HTTPError)

func PageFuncMap

func PageFuncMap(urlGenerator URLGenerator) template.FuncMap

func PageHandler

func PageHandler[T Resolver]() func(T) error

func PageMiddleware

func PageMiddleware[T Resolver](
	handler func(e T) error,
	selector PageSelector,
	strategy PageDecoratorStrategy,
	authorizer PageAuthorizer[T],
	skippers ...middleware.Skipper[T],
) func(T) error

func SiteMiddleware

func SiteMiddleware[T Resolver](selector SiteSelector, skippers ...middleware.Skipper[T]) func(T) error

Types

type Decision

type Decision int8
const (
	Deny Decision = iota
	Allow
)

func (Decision) String

func (d Decision) String() string

type DefaultPageManager

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

func NewPageManager

func NewPageManager(store PageStore) *DefaultPageManager

func (*DefaultPageManager) GetByAlias

func (m *DefaultPageManager) GetByAlias(ctx context.Context, site *Site, alias string) (*Page, error)

func (*DefaultPageManager) GetByID

func (m *DefaultPageManager) GetByID(ctx context.Context, id ID) (*Page, error)

func (*DefaultPageManager) GetByPattern

func (m *DefaultPageManager) GetByPattern(ctx context.Context, site *Site, pattern string) (*Page, error)

func (*DefaultPageManager) GetByURL

func (m *DefaultPageManager) GetByURL(ctx context.Context, site *Site, url string) (*Page, error)

type DefaultPageSelector

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

func NewPageSelector

func NewPageSelector(manager PageManager) *DefaultPageSelector

func (*DefaultPageSelector) Retrieve

func (s *DefaultPageSelector) Retrieve(r *http.Request, site *Site) (*Page, error)

type DefaultPageSyncer

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

func NewDefaultPageSyncer

func NewDefaultPageSyncer(
	cfg PageSyncerConfig,
	store PageStore,
	generator IDGenerator,
	patterns Patterns,
	strategy PageDecoratorStrategy,
) *DefaultPageSyncer

func (*DefaultPageSyncer) Sync

func (s *DefaultPageSyncer) Sync(ctx context.Context, site *Site) error

type DefaultSiteSelector

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

func NewSiteSelector

func NewSiteSelector(
	store SiteStore,
	countryFunc func(*http.Request) (string, error),
	errorFunc func(*http.Request, error) (*Site, error),
) *DefaultSiteSelector

func (*DefaultSiteSelector) Retrieve

func (s *DefaultSiteSelector) Retrieve(r *http.Request) (*Site, string, error)

type DenyPageAuthorizer

type DenyPageAuthorizer[T Resolver] struct{}

func (DenyPageAuthorizer[T]) Authorize

func (DenyPageAuthorizer[T]) Authorize(T, PageAction) (Decision, error)

type ErrorPatternFinderFunc

type ErrorPatternFinderFunc func(ctx context.Context, status int) (string, error)

func ErrorPatternFinder

func ErrorPatternFinder() ErrorPatternFinderFunc

type Event

type Event struct {
	wo.Event
	// contains filtered or unexported fields
}

func (*Event) Content

func (e *Event) Content() template.HTML

func (*Event) Error

func (e *Event) Error() error

func (*Event) HasPage

func (e *Event) HasPage() bool

func (*Event) HasSite

func (e *Event) HasSite() bool

func (*Event) IsDecorable

func (e *Event) IsDecorable() bool

func (*Event) IsGuest

func (e *Event) IsGuest() bool

func (*Event) IsRoot

func (e *Event) IsRoot() bool

func (*Event) Page

func (e *Event) Page() *Page

func (*Event) Pattern

func (e *Event) Pattern() string

func (*Event) Render

func (e *Event) Render(status int, contentType, template string) error

func (*Event) RenderHTML

func (e *Event) RenderHTML(status int, template string) error

func (*Event) Reset

func (e *Event) Reset(w *wo.Response, r *http.Request, t Theme)

func (*Event) SEO

func (e *Event) SEO() *SEO

func (*Event) SetContent

func (e *Event) SetContent(content template.HTML)

func (*Event) SetError

func (e *Event) SetError(err error)

func (*Event) SetGuest

func (e *Event) SetGuest(guest bool)

func (*Event) SetPage

func (e *Event) SetPage(page *Page)

func (*Event) SetSite

func (e *Event) SetSite(site *Site)

func (*Event) SetStatus

func (e *Event) SetStatus(status int)

func (*Event) SetTheme

func (e *Event) SetTheme(t Theme)

func (*Event) Site

func (e *Event) Site() *Site

func (*Event) Status

func (e *Event) Status() int

func (*Event) Theme

func (e *Event) Theme() Theme

func (*Event) View

func (e *Event) View(template string, data any) ([]byte, error)
type HeadLink struct {
	// CrossOrigin Specifies how the element handles cross-origin requests
	CrossOrigin string
	// Href Specifies the location of the linked document
	Href string
	// HrefLang Specifies the language of the text in the linked document
	HrefLang string
	// Media Specifies on what device the linked document will be displayed
	Media string
	// Rel REQUIRED Specifies the relationship between the current document and the linked document
	Rel string
	// Sizes Specifies the size of the linked resource. Only for rel="icon"
	Sizes string
	// Title Defines a preferred or an alternate stylesheet
	Title string
	// Type Specifies the media type of the linked document
	Type string
}

type ID

type ID string

func (ID) IsZero

func (id ID) IsZero() bool

func (ID) String

func (id ID) String() string

type IDGenerator

type IDGenerator func(ctx context.Context) (ID, error)

type LocalhostSiteStore

type LocalhostSiteStore struct{}

func NewLocalhostSiteStore

func NewLocalhostSiteStore() *LocalhostSiteStore

func (*LocalhostSiteStore) FindPublished

func (s *LocalhostSiteStore) FindPublished(context.Context) iter.Seq2[*Site, error]

type MemoryPageStore

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

func NewMemoryPageStore

func NewMemoryPageStore() *MemoryPageStore

func (*MemoryPageStore) DeleteByID

func (s *MemoryPageStore) DeleteByID(_ context.Context, ids ...ID) error

func (*MemoryPageStore) FindByAlias

func (s *MemoryPageStore) FindByAlias(_ context.Context, siteID ID, alias string) (*Page, error)

func (*MemoryPageStore) FindByID

func (s *MemoryPageStore) FindByID(_ context.Context, id ID) (*Page, error)

func (*MemoryPageStore) FindByPattern

func (s *MemoryPageStore) FindByPattern(_ context.Context, siteID ID, pattern string) (*Page, error)

func (*MemoryPageStore) FindByPatterns

func (s *MemoryPageStore) FindByPatterns(_ context.Context, siteID ID, patterns ...string) iter.Seq2[*Page, error]

func (*MemoryPageStore) FindByURL

func (s *MemoryPageStore) FindByURL(_ context.Context, siteID ID, url string) (*Page, error)

func (*MemoryPageStore) GetData

func (s *MemoryPageStore) GetData() []*Page

GetData returns a copy of the data slice for testing purposes. This method provides thread-safe access to the internal data.

func (*MemoryPageStore) Save

func (s *MemoryPageStore) Save(_ context.Context, pages ...*Page) error

type MetaTags

type MetaTags struct {
	Charset   string              `json:"charset,omitempty" yaml:"charset,omitempty"`
	Name      map[string][]string `json:"name,omitempty" yaml:"name,omitempty"`
	Property  map[string][]string `json:"property,omitempty" yaml:"property,omitempty"`
	HTTPEquiv map[string][]string `json:"httpEquiv,omitempty" yaml:"httpEquiv,omitempty"`
}

func NewMetaTags

func NewMetaTags(charset string, other ...*MetaTags) *MetaTags

func (*MetaTags) Append

func (m *MetaTags) Append(other *MetaTags)

func (*MetaTags) AppendHTTPEquiv

func (m *MetaTags) AppendHTTPEquiv(name string, content ...string)

func (*MetaTags) AppendName

func (m *MetaTags) AppendName(name string, content ...string)

func (*MetaTags) AppendProperty

func (m *MetaTags) AppendProperty(name string, content ...string)

func (*MetaTags) Set

func (m *MetaTags) Set(other *MetaTags)

func (*MetaTags) SetHTTPEquiv

func (m *MetaTags) SetHTTPEquiv(name string, content ...string)

func (*MetaTags) SetName

func (m *MetaTags) SetName(name string, content ...string)

func (*MetaTags) SetProperty

func (m *MetaTags) SetProperty(name string, content ...string)

func (*MetaTags) With

func (m *MetaTags) With(other *MetaTags) *MetaTags

type Metadata

type Metadata map[string]any

func NewMetadata

func NewMetadata(m map[string]any) Metadata

func (Metadata) Bool

func (m Metadata) Bool(key string) bool

func (Metadata) BoolSlice

func (m Metadata) BoolSlice(key string) []bool

func (Metadata) Delete

func (m Metadata) Delete(key string)

func (Metadata) Duration

func (m Metadata) Duration(key string) time.Duration

func (Metadata) Float32

func (m Metadata) Float32(key string) float32

func (Metadata) Float64

func (m Metadata) Float64(key string) float64

func (Metadata) Get

func (m Metadata) Get(key string) any

func (Metadata) GetOK

func (m Metadata) GetOK(key string) (any, bool)

func (Metadata) Has

func (m Metadata) Has(key string) bool

func (Metadata) Int

func (m Metadata) Int(key string) int

func (Metadata) Int16

func (m Metadata) Int16(key string) int16

func (Metadata) Int32

func (m Metadata) Int32(key string) int32

func (Metadata) Int64

func (m Metadata) Int64(key string) int64

func (Metadata) Int8

func (m Metadata) Int8(key string) int8

func (Metadata) IntSlice

func (m Metadata) IntSlice(key string) []int

func (Metadata) Set

func (m Metadata) Set(key string, value any)

func (Metadata) Slice

func (m Metadata) Slice(key string) []any

func (Metadata) Str

func (m Metadata) Str(key string) string

func (Metadata) StrSlice

func (m Metadata) StrSlice(key string) []string

func (Metadata) Time

func (m Metadata) Time(key string) time.Time

func (Metadata) Uint

func (m Metadata) Uint(key string) uint

func (Metadata) Uint16

func (m Metadata) Uint16(key string) uint16

func (Metadata) Uint32

func (m Metadata) Uint32(key string) uint32

func (Metadata) Uint64

func (m Metadata) Uint64(key string) uint64

func (Metadata) Uint8

func (m Metadata) Uint8(key string) uint8

type NoopPageDecoratorStrategy

type NoopPageDecoratorStrategy struct{}

func (*NoopPageDecoratorStrategy) IsDecorable

func (s *NoopPageDecoratorStrategy) IsDecorable(ctx context.Context, pattern, uri string) (bool, error)

func (*NoopPageDecoratorStrategy) IsPatternDecorable

func (s *NoopPageDecoratorStrategy) IsPatternDecorable(context.Context, string) (bool, error)

func (*NoopPageDecoratorStrategy) IsURIDecorable

func (s *NoopPageDecoratorStrategy) IsURIDecorable(context.Context, string) (bool, error)

type Page

type Page struct {
	ID ID `json:"id,omitempty" yaml:"id,omitempty"`

	SiteID ID    `json:"siteID,omitempty" yaml:"siteID,omitempty"`
	Site   *Site `json:"site,omitempty" yaml:"site,omitempty"`

	ParentID *ID     `json:"parentID,omitempty" yaml:"parentID,omitempty"`
	Parent   *Page   `json:"parent,omitempty" yaml:"parent,omitempty"`
	Children []*Page `json:"children,omitempty" yaml:"children,omitempty"`

	Created time.Time `json:"created,omitzero" yaml:"created,omitempty"`
	Updated time.Time `json:"updated,omitzero" yaml:"updated,omitempty"`

	Status     Status     `json:"status,omitempty" yaml:"status,omitempty"`
	Visibility Visibility `json:"visibility,omitempty" yaml:"visibility,omitempty"`

	MetaTags *MetaTags           `json:"metaTags,omitempty" yaml:"metaTags,omitempty"`
	Metadata Metadata            `json:"metadata,omitempty" yaml:"metadata,omitempty"`
	Header   map[string][]string `json:"header,omitempty" yaml:"header,omitempty"`

	Name      string `json:"name,omitempty" yaml:"name,omitempty"`
	Title     string `json:"title,omitempty" yaml:"title,omitempty"`
	Pattern   string `json:"pattern,omitempty" yaml:"pattern,omitempty"`
	Alias     string `json:"alias,omitempty" yaml:"alias,omitempty"`
	Slug      string `json:"slug,omitempty" yaml:"slug,omitempty"`
	URL       string `json:"url,omitempty" yaml:"url,omitempty"`
	CustomURL string `json:"customURL,omitempty" yaml:"customURL,omitempty"`
	Template  string `json:"template,omitempty" yaml:"template,omitempty"`
	Position  int    `json:"position,omitempty" yaml:"position,omitempty"`
	Decorate  bool   `json:"decorate,omitempty" yaml:"decorate,omitempty"`
}

func NewPage

func NewPage() *Page

func (*Page) AbsURL

func (p *Page) AbsURL(args ...any) string

func (*Page) Copy

func (p *Page) Copy() *Page

func (*Page) FixURL

func (p *Page) FixURL()

func (*Page) IsCMS

func (p *Page) IsCMS() bool

func (*Page) IsDynamic

func (p *Page) IsDynamic() bool

func (*Page) IsError

func (p *Page) IsError() bool

func (*Page) IsHybrid

func (p *Page) IsHybrid() bool

func (*Page) IsInternal

func (p *Page) IsInternal() bool

func (*Page) SetAlias

func (p *Page) SetAlias(alias string)

func (*Page) String

func (p *Page) String() string

type PageAction

type PageAction int8
const (
	ViewDraftPage PageAction = iota + 1
	ViewPrivatePage
	CreatePage
)

func (PageAction) String

func (a PageAction) String() string

type PageAuthorizer

type PageAuthorizer[T Resolver] interface {
	Authorize(e T, action PageAction) (Decision, error)
}

type PageConfig

type PageConfig struct {
	ParentID   *ID                 `json:"parentID,omitempty" yaml:"parentID,omitempty"`
	Template   *string             `json:"template,omitempty" yaml:"template,omitempty"`
	Position   *int                `json:"position,omitempty" yaml:"position,omitempty"`
	Decorate   *bool               `json:"decorate,omitempty" yaml:"decorate,omitempty"`
	Status     *Status             `json:"status,omitempty" yaml:"status,omitempty"`
	Visibility *Visibility         `json:"visibility,omitempty" yaml:"visibility,omitempty"`
	MetaTags   *MetaTags           `json:"metaTags,omitempty" yaml:"metaTags,omitempty"`
	Metadata   Metadata            `json:"metadata,omitempty" yaml:"metadata,omitempty"`
	Header     map[string][]string `json:"header,omitempty" yaml:"header,omitempty"`
}

type PageCreate

type PageCreate[T Resolver] struct {
	// contains filtered or unexported fields
}

func NewPageCreate

func NewPageCreate[T Resolver](store PageStore, beforeSave func(ctx context.Context, page *Page) error) *PageCreate[T]

func (*PageCreate[T]) Handle

func (h *PageCreate[T]) Handle(e T) error

type PageCreateRequest

type PageCreateRequest struct {
	URL      string `json:"url,omitempty" form:"url,omitempty"`
	Template string `json:"template,omitempty" form:"template,omitempty"`
	Title    string `json:"title,omitempty" form:"title,omitempty"`
}

func (*PageCreateRequest) Validate

func (r *PageCreateRequest) Validate() error

type PageDecoratorStrategy

type PageDecoratorStrategy interface {
	IsDecorable(ctx context.Context, pattern, uri string) (bool, error)
	IsPatternDecorable(ctx context.Context, pattern string) (bool, error)
	IsURIDecorable(ctx context.Context, uri string) (bool, error)
}

type PageManager

type PageManager interface {
	GetByID(ctx context.Context, id ID) (*Page, error)
	GetByURL(ctx context.Context, site *Site, url string) (*Page, error)
	GetByPattern(ctx context.Context, site *Site, pattern string) (*Page, error)
	GetByAlias(ctx context.Context, site *Site, alias string) (*Page, error)
}

type PageSelector

type PageSelector interface {
	Retrieve(r *http.Request, site *Site) (*Page, error)
}

type PageStore

type PageStore interface {
	FindByID(ctx context.Context, id ID) (*Page, error)
	FindByURL(ctx context.Context, siteID ID, url string) (*Page, error)
	FindByPattern(ctx context.Context, siteID ID, pattern string) (*Page, error)
	FindByPatterns(ctx context.Context, siteID ID, patterns ...string) iter.Seq2[*Page, error]
	FindByAlias(ctx context.Context, siteID ID, alias string) (*Page, error)
	Save(ctx context.Context, pages ...*Page) error
}

type PageSyncer

type PageSyncer interface {
	Sync(ctx context.Context, site *Site) error
}

type PageSyncerConfig

type PageSyncerConfig struct {
	DefaultPage     *PageConfig            `json:"defaultPage,omitempty" yaml:"defaultPage,omitempty"`
	DefaultPatterns map[string]*PageConfig `json:"defaultPatterns,omitempty" yaml:"defaultPatterns,omitempty"`
}

func (*PageSyncerConfig) SetDefaults

func (c *PageSyncerConfig) SetDefaults()

type PageURLGenerator

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

func NewPageURLGenerator

func NewPageURLGenerator(manager PageManager) *PageURLGenerator

func (*PageURLGenerator) Generate

func (g *PageURLGenerator) Generate(ctx context.Context, site *Site, arg any, args ...any) (string, error)

func (*PageURLGenerator) GenerateByAlias

func (g *PageURLGenerator) GenerateByAlias(ctx context.Context, site *Site, alias string, args ...any) (string, error)

func (*PageURLGenerator) GenerateByID

func (g *PageURLGenerator) GenerateByID(ctx context.Context, site *Site, id ID, args ...any) (string, error)

func (*PageURLGenerator) GenerateByPage

func (g *PageURLGenerator) GenerateByPage(site *Site, page *Page, args ...any) (string, error)

func (*PageURLGenerator) GenerateByPattern

func (g *PageURLGenerator) GenerateByPattern(ctx context.Context, site *Site, pattern string, args ...any) (string, error)

func (*PageURLGenerator) GenerateByURL

func (g *PageURLGenerator) GenerateByURL(ctx context.Context, site *Site, url string, args ...any) (string, error)

type Patterns

type Patterns interface {
	Patterns() iter.Seq[string]
}

type Resolver

type Resolver interface {
	wo.Resolver

	// Scheme returns the HTTP protocol scheme, `http` or `https`.
	Scheme() string
	BindBody(dst any) error

	Site() *Site
	SetSite(site *Site)
	HasSite() bool

	Page() *Page
	SetPage(page *Page)
	HasPage() bool

	Status() int
	SetStatus(status int)

	SetError(err error)
	SetContent(content template.HTML)

	IsGuest() bool
	IsDecorable() bool

	NoContent(status int) error
	Render(status int, contentType, template string) error
}

type SEO

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

func NewSEO

func NewSEO() *SEO

func (*SEO) AddArticleSection

func (s *SEO) AddArticleSection(section string)

func (*SEO) AddArticleTag

func (s *SEO) AddArticleTag(tag string)
func (s *SEO) AddCanonicalLink(href string)

func (*SEO) AddHTMLPrefixAttribute

func (s *SEO) AddHTMLPrefixAttribute(prefix string)

func (*SEO) AddLangAlternate

func (s *SEO) AddLangAlternate(href, hreflang string)
func (s *SEO) AddLink(link ...HeadLink)
func (s *SEO) AddNextLink(href string)
func (s *SEO) AddPrevLink(href string)

func (*SEO) AddTitle

func (s *SEO) AddTitle(title string)

func (*SEO) BodyAttributes

func (s *SEO) BodyAttributes() map[string]string

func (*SEO) FirstTitle

func (s *SEO) FirstTitle() string

func (*SEO) HTMLAttributes

func (s *SEO) HTMLAttributes() map[string]string

func (*SEO) HasBodyAttribute

func (s *SEO) HasBodyAttribute(name string) bool

func (*SEO) HasHTMLAttribute

func (s *SEO) HasHTMLAttribute(name string) bool

func (*SEO) HasHeadAttribute

func (s *SEO) HasHeadAttribute(name string) bool

func (*SEO) HasLangAlternate

func (s *SEO) HasLangAlternate(href string) bool

func (*SEO) HeadAttributes

func (s *SEO) HeadAttributes() map[string]string

func (*SEO) LangAlternates

func (s *SEO) LangAlternates() map[string]string
func (s *SEO) Links() []HeadLink

func (*SEO) MergeMetaTags

func (s *SEO) MergeMetaTags(metaTags *MetaTags)

func (*SEO) MetaTags

func (s *SEO) MetaTags() *MetaTags

func (*SEO) Page

func (s *SEO) Page(page *Page, args ...any)

func (*SEO) RemoveBodyAttribute

func (s *SEO) RemoveBodyAttribute(name string)

func (*SEO) RemoveHTMLAttribute

func (s *SEO) RemoveHTMLAttribute(name string)

func (*SEO) RemoveHeadAttribute

func (s *SEO) RemoveHeadAttribute(name string)

func (*SEO) RemoveLangAlternate

func (s *SEO) RemoveLangAlternate(href string)

func (*SEO) Reset

func (s *SEO) Reset()

func (*SEO) ReverseTitle

func (s *SEO) ReverseTitle() string

func (*SEO) Separator

func (s *SEO) Separator() string

func (*SEO) SetArticleExpirationTime

func (s *SEO) SetArticleExpirationTime(expired time.Time)

func (*SEO) SetArticleModifiedTime

func (s *SEO) SetArticleModifiedTime(updated time.Time)

func (*SEO) SetArticlePublishedTime

func (s *SEO) SetArticlePublishedTime(published time.Time)

func (*SEO) SetArticleType

func (s *SEO) SetArticleType()

func (*SEO) SetBodyAttribute

func (s *SEO) SetBodyAttribute(name, content string)

func (*SEO) SetBodyAttributes

func (s *SEO) SetBodyAttributes(attrs map[string]string)

func (*SEO) SetHTMLAttribute

func (s *SEO) SetHTMLAttribute(name, content string)

func (*SEO) SetHTMLAttributes

func (s *SEO) SetHTMLAttributes(attrs map[string]string)

func (*SEO) SetHeadAttribute

func (s *SEO) SetHeadAttribute(name, content string)

func (*SEO) SetHeadAttributes

func (s *SEO) SetHeadAttributes(attrs map[string]string)

func (*SEO) SetLangAlternates

func (s *SEO) SetLangAlternates(langAlternates map[string]string)
func (s *SEO) SetLinks(links []HeadLink)

func (*SEO) SetOGType

func (s *SEO) SetOGType(t string)

func (*SEO) SetOgURL

func (s *SEO) SetOgURL(url string)

func (*SEO) SetSeparator

func (s *SEO) SetSeparator(separator string)

func (*SEO) SetTitle

func (s *SEO) SetTitle(title string)

func (*SEO) SetWebsiteType

func (s *SEO) SetWebsiteType()

func (*SEO) Site

func (s *SEO) Site(site *Site)

func (*SEO) Title

func (s *SEO) Title() string

type Site

type Site struct {
	ID ID `json:"id,omitempty" yaml:"id,omitempty"`

	Created time.Time `json:"created,omitzero" yaml:"created,omitempty"`
	Updated time.Time `json:"updated,omitzero" yaml:"updated,omitempty"`

	Status Status `json:"status,omitempty" yaml:"status,omitempty"`

	MetaTags *MetaTags `json:"metaTags,omitempty" yaml:"metaTags,omitempty"`
	Metadata Metadata  `json:"metadata,omitempty" yaml:"metadata,omitempty"`

	Name      string   `json:"name,omitempty" yaml:"name,omitempty"`
	Title     string   `json:"title,omitempty" yaml:"title,omitempty"`
	Separator string   `json:"separator,omitempty" yaml:"separator,omitempty"`
	Locale    string   `json:"locale,omitempty" yaml:"locale,omitempty"`
	Timezone  string   `json:"timezone,omitempty" yaml:"timezone,omitempty"`
	Countries []string `json:"countries,omitempty" yaml:"countries,omitempty"`

	Scheme       string `json:"scheme,omitempty" yaml:"scheme,omitempty"`
	Host         string `json:"host,omitempty" yaml:"host,omitempty"`
	RelativePath string `json:"relativePath,omitempty" yaml:"relativePath,omitempty"`
	IsDefault    bool   `json:"isDefault,omitempty" yaml:"isDefault,omitempty"`
	// contains filtered or unexported fields
}

func NewSite

func NewSite() *Site

func (*Site) Copy

func (s *Site) Copy() *Site

func (*Site) Home

func (s *Site) Home() string

func (*Site) IsLocalhost

func (s *Site) IsLocalhost() bool

func (*Site) Location

func (s *Site) Location() *time.Location

func (*Site) Origin

func (s *Site) Origin() string

func (*Site) String

func (s *Site) String() string

func (*Site) Tag

func (s *Site) Tag() language.Tag

func (*Site) URL

func (s *Site) URL() string

type SiteSelector

type SiteSelector interface {
	Retrieve(r *http.Request) (*Site, string, error)
}

type SiteStore

type SiteStore interface {
	FindPublished(ctx context.Context) iter.Seq2[*Site, error]
}

type Status

type Status int8
const (
	Draft Status = iota
	Published
)

func StatusFromString

func StatusFromString(s string) Status

func (Status) String

func (s Status) String() string

type Theme

type Theme interface {
	Write(ctx context.Context, w io.Writer, template string, data any) error
}

type URLGenerator

type URLGenerator interface {
	Generate(ctx context.Context, site *Site, arg any, args ...any) (string, error)
}

type Visibility

type Visibility int8
const (
	Private Visibility = iota
	Public
)

func VisibilityFromString

func VisibilityFromString(s string) Visibility

func (Visibility) String

func (v Visibility) String() string

Jump to

Keyboard shortcuts

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