Documentation
¶
Overview ¶
templ: version: v0.3.1020
templ: version: v0.3.1020
templ: version: v0.3.1020
templ: version: v0.3.1020
Index ¶
- Variables
- func OptimizedImage(componentProps OptimizedImageProps) templ.Component
- func RuntimeScripts() templ.Component
- func SigV4Enabled() bool
- func StatefulComponent(path string, method routes.HttpMethod, vals string, hasVals bool) templ.Component
- func StatefulComponentOf[T any](config *routes.RouteConfig[T], vals ...StatefulComponentData) templ.Component
- func Styles() templ.Component
- type OptimizedImageProps
- type StatefulComponentData
Constants ¶
This section is empty.
Variables ¶
View Source
var OptimizedImageConfig = routes.RouteConfig[OptimizedImageProps]{ Type: routes.STATIC, HttpMethod: routes.GET, Middleware: func(w http.ResponseWriter, r *http.Request) OptimizedImageProps { imgName := chi.URLParam(r, "name") imgExtension := chi.URLParam(r, "extension") imgAlt := r.URL.Query().Get("alt") return OptimizedImageProps{ IsFirstLoad: false, ImgName: imgName, ImgExtension: imgExtension, Alt: imgAlt, } }, }
*
- `OptimizedImageConfig` sets up a route for serving optimized images with lazy loading. *
- - `Type`: Set to `STATIC` so images are cached by CloudFront and served instantly from edge locations.
- - `HttpMethod`: Uses `GET`, which works seamlessly with HTMX for background fetching.
- - `Middleware`: Extracts route parameters (`:name`, `:extension`) and query parameters (`alt`) to
- generate the image rendering props. `IsFirstLoad` is always `false` here because only the initial
- blurred image (rendered from the parent page/component) sets it to `true`. `Priority` is always
- `false` on this HTMX follow-up path — priority images are rendered inline by the parent and never
- reach this endpoint.
Functions ¶
func OptimizedImage ¶
func OptimizedImage(componentProps OptimizedImageProps) templ.Component
func RuntimeScripts ¶
func SigV4Enabled ¶ added in v1.2.0
func SigV4Enabled() bool
SigV4Enabled reports whether the app is deployed on AWS (read once at process start, mirroring the GOTHIC_MODE pattern). When true, RuntimeScripts emits the WASM AWS request-signing enable flag + boot-race coordination shim.
func StatefulComponent ¶
func StatefulComponentOf ¶
func StatefulComponentOf[T any]( config *routes.RouteConfig[T], vals ...StatefulComponentData, ) templ.Component
Types ¶
type OptimizedImageProps ¶
type OptimizedImageProps = struct {
IsFirstLoad bool
ImgName string
ImgExtension string
Alt string
Priority bool
}
*
- `OptimizedImageProps` defines the input props for the OptimizedImage component. *
- Fields:
- - `IsFirstLoad`: Indicates whether this is the initial blurred image request.
- - This should only be set to `true` when rendered from another component or page (like `Index`).
- - When HTMX triggers the `load` event to swap in the full image, `IsFirstLoad` is automatically `false`.
- - For a usage example, refer to the `Index` page implementation.
- - `ImgName`: The base name of the image file (e.g., "logo").
- - `ImgExtension`: The file extension (e.g., "jpeg", "png").
- - `Alt`: The image's alt text — important for accessibility and SEO.
- - `Priority`: Set `true` for an above-the-fold / LCP (Largest Contentful Paint) image.
- - The full-resolution `<img>` is then rendered DIRECTLY in the initial HTML (not
- fetched later via HTMX), so the browser's preload scanner discovers it immediately.
- - It is marked `fetchpriority="high"` and is NOT lazy-loaded, so the LCP image starts
- downloading as early as possible.
- - Leave it `false` (the default) for below-the-fold images: those keep the
- blur-up placeholder + lazy `loading="lazy"` behavior. *
- NOTE: prefer KEYED struct literals — e.g. `OptimizedImageProps{ImgName: "logo", ImgExtension: "png", Alt: "…"}`
- — so future field additions never break your call sites.
type StatefulComponentData ¶
Click to show internal directories.
Click to hide internal directories.