Documentation
¶
Index ¶
- func Merge(maps ...template.FuncMap) template.FuncMap
- type Analytics
- type CMS
- func (cms *CMS) LastUpdate() string
- func (cms *CMS) Render(page *Content, content []Content) template.HTML
- func (cms *CMS) Render404(w http.ResponseWriter, r *http.Request, path string)
- func (cms *CMS) RenderPage(w http.ResponseWriter, r *http.Request, path string, page *Content)
- func (cms *CMS) Serve(w http.ResponseWriter, r *http.Request)
- func (cms *CMS) SetHandler(name string, handler Handler)
- type Cache
- type Content
- type Copy
- type Experiment
- type Handler
- type Options
- type Sitemap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Analytics ¶
type Analytics struct {
Tags map[string]string `json:"tags"`
Experiment Experiment `json:"experiment"`
}
Analytics is the analytics metadata for the Content.
type CMS ¶
type CMS struct {
// contains filtered or unexported fields
}
CMS manages pages and content.
func (*CMS) LastUpdate ¶
LastUpdate returns the time the website data has last been updated.
func (*CMS) RenderPage ¶
RenderPage renders given page and returns it to the client.
func (*CMS) Serve ¶
func (cms *CMS) Serve(w http.ResponseWriter, r *http.Request)
Serve renders the page for given path and writes the response to the http.ResponseWriter. If no page is found, it will redirect to the 404 page.
func (*CMS) SetHandler ¶
SetHandler sets the handler function for given name.
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache caches a HTML template directory.
func NewCache ¶
NewCache creates a new template cache for given directory and function map. disable is used to disable the cache for testing.
func (*Cache) Execute ¶
func (cache *Cache) Execute(w http.ResponseWriter, name string, data any)
Execute executes the template for given name. It logs errors and returns an error code, if something goes wrong.
type Content ¶
type Content struct {
DisableCache bool `json:"disable_cache"`
Path map[string]string `json:"path"`
Sitemap Sitemap `json:"sitemap"`
Header map[string]string `json:"header"`
Handler string `json:"handler"`
Analytics Analytics `json:"analytics"`
Ref string `json:"ref"`
Tpl string `json:"tpl"`
Data map[string]any `json:"data"`
Copy Copy `json:"copy"`
Content map[string][]Content `json:"content"`
// Language is extracted and set from Path automatically.
Language string `json:"-"`
// CanonicalLink is set automatically using the configured hostname and Path.
CanonicalLink string `json:"-"`
// Experiments is a list of A/B experiments extracted from the content (name -> variants).
Experiments map[string][]string `json:"-"`
// SelectedExperiments is a list of selected A/B experiments from the Experiments list.
SelectedExperiments map[string]string `json:"-"`
// SelectedPageExperiment is an experiment from the page experiments list, redirecting if the visitor is on the wrong page.
SelectedPageExperiment string `json:"-"`
}
Content is a page or element for the CMS.
type Experiment ¶
Experiment is an A/B testing experiment.