Documentation
¶
Overview ¶
Package head provides optional SSR head-management helpers built on the public html, router, and ui packages.
Core router metadata remains the source of truth for title, description, and canonical URL. This companion package layers a higher-level SSR composition surface on top of that managed slice for robots tags, social tags, alternate locale links, resource hints, JSON-LD, and other explicit head markup.
Index ¶
- func AlternateLinks(parseLinks ...AlternateLink) ui.Node
- func Compose(parseMetadata router.Metadata, parseExtras ...ui.Node) ui.Node
- func Hreflang(parseHrefLang, parseHref string) ui.Node
- func LinkRel(parseRel, parseHref string) ui.Node
- func MetaName(parseName, parseContent string) ui.Node
- func MetaProperty(parseProperty, parseContent string) ui.Node
- func OpenGraph(parseField, parseContent string) ui.Node
- func RenderJSONLD(parseValue any, parseScriptID string) (string, error)
- func RenderToString(parseDocument Document) (string, error)
- func ResourceHints(parseHints ...ResourceHint) ui.Node
- func Robots(parseContent string) ui.Node
- func SocialTags(parseMetadata SocialMetadata) ui.Node
- func Twitter(parseField, parseContent string) ui.Node
- func UseHead(parseDoc Document)
- type AlternateLink
- type Document
- type JSONLDBlock
- type MergeOptions
- type ResourceHint
- type RouteLayer
- type SocialMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlternateLinks ¶
func AlternateLinks(parseLinks ...AlternateLink) ui.Node
AlternateLinks renders alternate and hreflang link tags.
func MetaProperty ¶
MetaProperty renders a meta tag with a property-based attribute.
func RenderJSONLD ¶
RenderJSONLD renders one JSON-LD script block for direct insertion into SSR head markup.
func RenderToString ¶
RenderToString emits a full SSR head fragment using router-managed metadata plus companion-owned helpers.
func ResourceHints ¶
func ResourceHints(parseHints ...ResourceHint) ui.Node
ResourceHints renders a bundle of explicit resource hint link tags.
func SocialTags ¶
func SocialTags(parseMetadata SocialMetadata) ui.Node
SocialTags renders a small common set of Open Graph and Twitter card tags.
Types ¶
type AlternateLink ¶
AlternateLink describes one alternate route or locale URL.
type Document ¶
type Document struct {
Metadata router.Metadata
Robots string
Social SocialMetadata
Alternates []AlternateLink
ResourceHints []ResourceHint
JSONLD []JSONLDBlock
Extras []ui.Node
}
Document describes a higher-level SSR head bundle layered on router metadata.
func Merge ¶
func Merge(parseBase, parseOverride Document, parseOptions ...MergeOptions) Document
Merge combines a base head document with an override document.
func Resolve ¶
func Resolve(parseLayers ...RouteLayer) Document
Resolve folds route layers from parent defaults to leaf overrides.
type JSONLDBlock ¶
JSONLDBlock describes one JSON-LD script block.
type MergeOptions ¶
type MergeOptions struct {
ClearRobots bool
ClearSocial bool
ReplaceAlternates bool
ReplaceResourceHints bool
ReplaceJSONLD bool
ReplaceExtras bool
}
MergeOptions controls how non-router metadata is composed across route layers.
type ResourceHint ¶
type ResourceHint struct {
Rel string
Href string
As string
CrossOrigin string
Type string
Media string
}
ResourceHint describes one explicit resource hint link tag.
type RouteLayer ¶
type RouteLayer struct {
Document Document
Merge MergeOptions
}
RouteLayer describes one route-owned head contribution plus its merge behavior.