pages

package
v0.54.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	NakedContent     bool
	Page             *page
	Sidebar          *page
	NoBoost          bool
	HotReload        bool
	OfficialInstance bool
	RequestInfo      RequestInfo
	PlausibleScript  string

	CurrentSection  string
	NavigationLinks interface{}
	Title           string

	UserID         string
	UserLoggedIn   bool
	UserHasAccount bool
	HasNews        bool
	Preferences    *db.UserPreference
	CSRFToken      string

	Data ContextData
}

func (*Context) Add

func (c *Context) Add(key string, value interface{})

type ContextBuilder added in v0.18.0

type ContextBuilder func(c echo.Context, title string) *Context

type ContextData

type ContextData map[string]interface{}

type Pages

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

Pages holds parsed pages ready for rendering

func LoadPages

func LoadPages() (*Pages, error)

LoadPages parses all web pages found in the pages folder

func (*Pages) BuildPageContext added in v0.18.0

func (p *Pages) BuildPageContext(c echo.Context, title string) *Context

func (*Pages) Redirect added in v0.18.0

func (p *Pages) Redirect(c echo.Context, code int, target string) error

func (*Pages) RedirectToPage added in v0.18.0

func (p *Pages) RedirectToPage(c echo.Context, name string, params ...interface{}) error

RedirectToPage the user to another page, either via htmx client-side Redirect (form submissions) or http 302 Redirect (direct access, js disabled)

func (*Pages) RegisterContextBuilder added in v0.18.0

func (p *Pages) RegisterContextBuilder(b ContextBuilder)

func (*Pages) RegisterHelpers

func (p *Pages) RegisterHelpers(helpers map[string]interface{})

func (*Pages) Render

func (p *Pages) Render(c echo.Context, name string, data *Context) error

func (*Pages) RenderWithSidebar

func (p *Pages) RenderWithSidebar(c echo.Context, name, sidebar string, data *Context) error

type RequestInfo

type RequestInfo interface {
	// Request returns `*http.Request`.
	Request() *http.Request
	// Scheme returns the HTTP protocol scheme, `http` or `https`.
	Scheme() string
}

RequestInfo is a subset of echo.Context

Jump to

Keyboard shortcuts

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