utils

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheControl

func CacheControl(policy string, next http.Handler) http.Handler

CacheControl returns middleware that sets the Cache-Control header to the given policy.

func EmbedFsFileHandler

func EmbedFsFileHandler(fs embed.FS, file string, contentType string) http.Handler

EmbedFsFileHandler reads a file from an embedded filesystem and returns a handler that serves it with caching.

func StaticByteHandler

func StaticByteHandler(b []byte, contentType string) http.Handler

StaticByteHandler returns a handler that serves static bytes with ETag-based cache validation.

func StaticPageHandler

func StaticPageHandler(ctx context.Context, c templ.Component) http.Handler

StaticPageHandler renders a templ component once at init and returns a handler that serves the resulting HTML.

Types

type ClickableHeadingRenderer

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

Wraps all headings in a anchor tag, so that they are clickable for navigation purposes.

Only headings that already have an ID attribute will be wrapped. parser.WithAutoHeadingID can be used to automatically add the ID attributes.

If multiple headings have the same ID, to avoid collision each subsequent ID will be suffixed with a sequence number.

func NewClickableHeadingRenderer

func NewClickableHeadingRenderer() *ClickableHeadingRenderer

func (*ClickableHeadingRenderer) RegisterFuncs

Jump to

Keyboard shortcuts

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