Documentation
¶
Index ¶
- Constants
- Variables
- func ExportJSX(name string, src []byte, globals map[string]any) (map[string]any, error)
- func RenderJSX(name string, src []byte, globals map[string]any, args ...any) ([]byte, error)
- func RenderTemplate(name string, src []byte, funcs template.FuncMap) ([]byte, error)
- type Data
- type JSXParser
- type MarkdownParser
- type Output
- type Page
- func (p *Page) Aliases() []string
- func (p *Page) Body() []byte
- func (p *Page) ContentType() string
- func (p *Page) Date() string
- func (p *Page) Draft() bool
- func (p *Page) IsDir() bool
- func (p *Page) Outputs() []*Output
- func (p *Page) Parse() error
- func (p *Page) Preamble() string
- func (p *Page) Render(w io.Writer) (err error)
- func (p *Page) Slug() string
- func (p *Page) Source() []byte
- func (p *Page) Subpages() (subpages []*Page)
- func (p *Page) Template() string
- func (p *Page) Time() time.Time
- func (p *Page) URL() string
- type PageParser
- type RedirectRule
- type Route
- type RouteKind
- type RouteTable
- type Site
- func (s *Site) Fonts() (*raster.Fonts, error)
- func (s *Site) GenerateAll(dest string, clobber bool) (err error)
- func (s *Site) IsPage(path string) bool
- func (s *Site) Page(normalPath string) *Page
- func (s *Site) Pages(query string) ([]*Page, error)
- func (s *Site) ParseAll() error
- func (s *Site) Partial(name string, globals map[string]any, args ...any) ([]byte, error)
- func (s *Site) Query(paths []string, where map[string]any) ([]*Page, error)
- func (s *Site) Routes() *RouteTable
- func (s *Site) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Site) WatchForReloads()
- type TemplateParser
Constants ¶
const ( ExtMarkdown = ".md" ExtTemplate = ".tmpl" ExtJSX = ".jsx" )
const ( // Links is the page data key for the pages a page's body links to. Links = "links" // Backlinks is the page data key for the pages that link to a page. Backlinks = "backlinks" // SiteURL is the page data key for the site's absolute origin, such as // "https://example.com", used to recognize absolute links to the site. SiteURL = "siteURL" )
const ( Layout = "layout" Slug = "slug" Path = "path" Source = "src" Body = "body" IsDir = "isDir" Date = "date" ContentType = "contentType" Draft = "draft" Preamble = "preamble" Outputs = "outputs" )
const Aliases = "aliases"
Aliases is the page data key listing old URL paths that redirect to the page.
const AssetsDir = "_assets"
AssetsDir is the root-level directory copied verbatim by build.
const OutputsDir = "_outputs"
OutputsDir is the directory that holds output templates, in any directory of the site.
const Params = "params"
Params is the page data key holding a generated page's parameter set.
const RedirectsFile = "_redirects"
RedirectsFile is the root file listing redirects, in a subset of Netlify's _redirects format.
Variables ¶
var Formats = map[string]PageParser{ ExtMarkdown: &MarkdownParser{}, ExtTemplate: &TemplateParser{}, ExtJSX: &JSXParser{}, }
Functions ¶
Types ¶
type MarkdownParser ¶
type MarkdownParser struct{}
type Output ¶
type Output struct {
// Name is the output's name, such as "card" for _outputs/card.png.jsx.
Name string
// Suffix is appended to the page's URL, such as ".card.png".
Suffix string
// Template is the template's path relative to the site root.
Template string
// Page is the page the output belongs to.
Page *Page
}
Output is an extra file written for a page by an _outputs template.
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
func (*Page) ContentType ¶
func (*Page) Outputs ¶
Outputs returns the page's outputs that apply to it and are turned on, as of its last parse.
type RedirectRule ¶
type RedirectRule struct {
// Line is the rule's line number in _redirects, from 1.
Line int
// From is the normalized source path. For a wildcard rule it is the path
// the wildcard is below, without "/*".
From string
// Wildcard is true when the rule's from ended in "/*".
Wildcard bool
// To is the target as written: a path, possibly with a query string, or
// an absolute http or https URL, possibly containing :splat.
To string
// Status is the redirect's HTTP status.
Status int
}
RedirectRule is one rule from the _redirects file.
func (*RedirectRule) String ¶
func (r *RedirectRule) String() string
type Route ¶
type Route struct {
Kind RouteKind
// URL is the path the route is served at, such as "/", "/about",
// "/about.txt", or "/img/logo.svg".
URL string
// File is where build writes the route, relative to the output
// directory, such as "index.html" or "about/index.html".
File string
// Page is the page for page, output, and alias routes. For a redirect
// route it is the page a stub or copy is written for, if any.
Page *Page
// Output is the output for output routes.
Output *Output
// Source is the absolute source filename for static routes.
Source string
// Target is where an alias or redirect route points.
Target string
// Rule is the _redirects rule for redirect routes.
Rule *RedirectRule
}
Route is one URL the site serves and what produces it.
type RouteKind ¶
type RouteKind string
RouteKind says what produces a route's URL.
const ( // RoutePage is a page with a source file, or a page generated from a // template. RoutePage RouteKind = "page" // RouteOutput is an output of a page, from an _outputs template. RouteOutput RouteKind = "output" // RouteStatic is a file copied verbatim. RouteStatic RouteKind = "static" // RouteAlias is an old URL of a page, from its aliases. RouteAlias RouteKind = "alias" // RouteRedirect is a redirect from the _redirects file. RouteRedirect RouteKind = "redirect" )
type RouteTable ¶
type RouteTable struct {
// contains filtered or unexported fields
}
RouteTable maps every URL the site serves to what produces it. Each URL, and each output file, has exactly one producer.
func NewRouteTable ¶
func NewRouteTable() *RouteTable
func (*RouteTable) Add ¶
func (t *RouteTable) Add(r *Route) error
Add adds a route. A route whose URL or output file is already taken is an error naming both producers.
func (*RouteTable) Lookup ¶
func (t *RouteTable) Lookup(urlPath string) *Route
Lookup returns the route for a request path, ignoring leading and trailing slashes, or nil.
func (*RouteTable) Routes ¶
func (t *RouteTable) Routes() []*Route
Routes returns every route, ordered by output file.
type Site ¶
type Site struct {
// contains filtered or unexported fields
}
func (*Site) ParseAll ¶
ParseAll resets the page map, parses every page found by walk, generates the pages for every template from the real pages, builds the route table, and builds the link graph.
func (*Site) Query ¶
Query returns the union of the listings for each path or pattern, once each, keeping only pages whose data matches every key in where, sorted as one listing.
func (*Site) Routes ¶
func (s *Site) Routes() *RouteTable
Routes returns the route table built by the last ParseAll.
func (*Site) WatchForReloads ¶
func (s *Site) WatchForReloads()
type TemplateParser ¶
type TemplateParser struct{}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
taragen
command
|
|
|
internal
|
|
|
design
Package design implements the proposal-driven design workflow described in design/README.md: parsing proposal frontmatter, validating proposals, and computing their state from git.
|
Package design implements the proposal-driven design workflow described in design/README.md: parsing proposal frontmatter, validating proposals, and computing their state from git. |
|
raster
Package raster turns SVG into PNG with resvg, compiled to WebAssembly and run by wazero, so taragen stays a pure-Go binary.
|
Package raster turns SVG into PNG with resvg, compiled to WebAssembly and run by wazero, so taragen stays a pure-Go binary. |
|
tools
|
|
|
design
command
Command design runs taragen's proposal-driven design workflow.
|
Command design runs taragen's proposal-driven design workflow. |
|
docs
command
Command docs splits MANUAL.md into the website's docs pages.
|
Command docs splits MANUAL.md into the website's docs pages. |