Documentation
¶
Overview ¶
Package fest is the main fest package
Index ¶
- func GetTitle(ctx context.Context) string
- type Generator
- func (g *Generator) AddRoute(path string, comp templ.Component) *Route
- func (g *Generator) AddRouteFunc(path string, fn func(context.Context) (templ.Component, error)) *Route
- func (g *Generator) Context() context.Context
- func (g *Generator) CopyDir(src, dst string)
- func (g *Generator) CopyFile(src, dst string)
- func (g *Generator) Generate() error
- type GeneratorConfig
- type HeadBody
- type Pagination
- type Route
- type RouteError
- type RouteFunc
- type RouteParam
- type Routes
- type SiteNameOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Generator ¶
type Generator struct {
HeadBody HeadBody
// contains filtered or unexported fields
}
Generator contains configuration for static files generation.
func NewGenerator ¶
func NewGenerator(ctx context.Context, siteName string, config *GeneratorConfig) *Generator
NewGenerator creates a new generator. Use nil to use default configs
func (*Generator) AddRoute ¶
AddRoute adds a single route with the specified path that will generate a file from the component relative from the Generator destination.
func (*Generator) AddRouteFunc ¶
func (g *Generator) AddRouteFunc( path string, fn func(context.Context) (templ.Component, error), ) *Route
AddRouteFunc adds a single route with the specified path that will generate a file from the component relative from the Generator destionation. All errors returned from this function will be handled in g.Generate method.
func (*Generator) CopyDir ¶
CopyDir copies src that is a directory to dst inside generated location. Will also copy the directory instead of the content-only. Relative from Source set of g.
type GeneratorConfig ¶
type GeneratorConfig struct {
// Don't use the built-in base template that is temfest.Base.
// Note that utilities that modify temfest.Base will be no-op,
// thus it is recommended to modify Head, Body, and BaseConfig instead.
NoBase bool
// Directory that will be used as root directory for finding necessary files.
// By default it's "."
Source string
// Directory where static files will be generated. By default it's "./dist".
Destination string
// SiteNameOption is the position in the title where the site's
// should be rendered. By default it's SiteNameBack.
SiteNameOption SiteNameOption
// Seperator is the string used to seperate page title with site's name.
// By default it's " - ".
Seperator string
// BaseConfig is temfest.Base config.
BaseConfig temfest.BaseConfig
}
GeneratorConfig is configurations for Generator.
type HeadBody ¶ added in v0.8.0
type HeadBody struct {
// contains filtered or unexported fields
}
HeadBody represents `<head>` and `<body>` tags. It is mainly used to append.
type Pagination ¶
type Pagination[T any] struct { // The current page number Current int // The total number of pages, or the last page. Total int // The chuck of data sliced with the set size from original data. Chunk []T }
Pagination contains the information of the current page route.
type Route ¶
type Route struct {
HeadBody HeadBody
// contains filtered or unexported fields
}
Route contains data necessary to generate a route.
func (*Route) BaseConfig ¶ added in v0.8.0
func (r *Route) BaseConfig(conf temfest.BaseConfig) *Route
func (*Route) OverrideBase ¶
OverrideBase overrides the base component. Note that it must have the implemented templ { children... }
type RouteError ¶
type RouteError struct {
// contains filtered or unexported fields
}
func (RouteError) Error ¶
func (r RouteError) Error() string
func (RouteError) Unwrap ¶
func (r RouteError) Unwrap() error
type RouteParam ¶ added in v0.3.0
RouteParam is the current route parameter.
func (*RouteParam[T]) BaseConfig ¶ added in v0.8.0
func (rp *RouteParam[T]) BaseConfig(conf temfest.BaseConfig)
BaseConfig sets the temfest.Base config for the current route. Unset/empty field will be no-op.
func (*RouteParam[T]) GetItem ¶ added in v0.3.0
func (rp *RouteParam[T]) GetItem() T
GetItem gets the current data item.
func (*RouteParam[T]) GetSlug ¶ added in v0.3.0
func (rp *RouteParam[T]) GetSlug() string
GetSlug gets the currently set slug.
func (*RouteParam[T]) SetSlug ¶ added in v0.3.0
func (rp *RouteParam[T]) SetSlug(slug string)
SetSlug sets the current slug.
func (*RouteParam[T]) SetTitle ¶ added in v0.7.0
func (rp *RouteParam[T]) SetTitle(title string)
SetTitle sets the current route title. It overrides the title sets for Routes.
type Routes ¶
Routes generates multiple routes. User must call AddToGenerator in order to add the routes to the Generator.
func NewPaginatedRoutes ¶
func NewPaginatedRoutes[T any](path string, data []T, size int) *Routes[*Pagination[T]]
NewPaginatedRoutes creates routes that will be paginated from data with specified size.
func NewRoutes ¶
NewRoutes creates routes from the data with specified size. By default, the slug will be the same as string item
func NewRoutesT ¶
NewRoutesT creates routes from the data with specified size. By default, the slug will be 1-based index of the item.
func (*Routes[T]) AddToGenerator ¶
AddToGenerator adds routes to the set Generator.
func (*Routes[T]) BaseConfig ¶ added in v0.8.0
func (rs *Routes[T]) BaseConfig(conf temfest.BaseConfig) *Routes[T]
BaseConfig sets the temfest.Base config for the routes. Unset/empty field will be no-op.
type SiteNameOption ¶ added in v0.8.0
type SiteNameOption int
SiteNameOption specifies the title options
const ( // Show the site title at the end SiteNameBack SiteNameOption = iota // Show the site title at the beginning SiteNameFront // Don't show site name in the title SiteNameNone )
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
basic/cmd
command
|
|
|
markdown/cmd
command
|
|
|
routes/cmd
command
|
|
|
internal
|
|
|
testfest
templ: version: v0.3.960
|
templ: version: v0.3.960 |
|
Package markdown provides utilities used for parsing mardown files.
|
Package markdown provides utilities used for parsing mardown files. |
|
templ: version: v0.3.960
|
templ: version: v0.3.960 |