Documentation
¶
Index ¶
- Variables
- func Merge(maps ...template.FuncMap) template.FuncMap
- type Analytics
- type CMS
- func (cms *CMS) LastUpdate() string
- func (cms *CMS) Render(args map[string]string, 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, args map[string]string, ...)
- func (cms *CMS) Serve(w http.ResponseWriter, r *http.Request)
- func (cms *CMS) SetHandler(name string, handler Handler)
- func (cms *CMS) Update()
- type Cache
- type Content
- type Copy
- type Experiment
- type Handler
- type Options
- type Route
- type Sitemap
- type Subroute
Constants ¶
This section is empty.
Variables ¶
var ( ErrMatcherBrackets = "matching route '%s' must end with a closing bracket" ErrMatcherEmpty = "matching route '%s' must not be empty" ErrMatcherVariable = "matching route '%s' must have a variable name (name:expression)" ErrParsingMatcher = "error parsing matching route '%s': %v" )
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) Render404 ¶
Render404 renders the 404 page for given path and language if it exists. The language will fall back to en if not found or empty.
func (*CMS) RenderPage ¶
func (cms *CMS) RenderPage(w http.ResponseWriter, r *http.Request, path string, args map[string]string, page *Content)
RenderPage renders given page and returns it to the client.
func (*CMS) Serve ¶
func (cms *CMS) Serve(w http.ResponseWriter, r *http.Request)
Serve matches the path and renders the page for given request. 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.
type Options ¶
type Options struct { Ctx context.Context BaseDir string HotReload bool NotFound map[string]string FuncMap template.FuncMap Source source.Provider Sitemap *sitemap.Sitemap }
Options is the CMS configuration.
type Route ¶ added in v0.11.0
type Route struct {
// contains filtered or unexported fields
}
Route matches raw or matching routes including regular expressions.