Documentation
¶
Overview ¶
Package document renders the complete SEO and hydration document around a body produced by GoBeyond's portable renderer.
Index ¶
Constants ¶
View Source
const ( TraceParentHeader = "traceparent" TraceStateHeader = "tracestate" TraceParentMeta = "traceparent" TraceStateMeta = "tracestate" )
W3C Trace Context header names. Hosts such as gbhost inject these on the document request; the HTML document then exposes them to JavaScript so same-origin fetches can continue the page request instead of starting a new root.
Variables ¶
This section is empty.
Functions ¶
func NormalizeTraceParent ¶
NormalizeTraceParent returns a lowercase W3C traceparent, or empty when the value is missing or invalid. Invalid values are dropped so they cannot be reflected into HTML or reused as a parent.
func NormalizeTraceState ¶
NormalizeTraceState returns a W3C tracestate value, or empty when it is missing or not safe to copy into HTML.
Types ¶
type HydrationData ¶
type HydrationData struct {
APIVersion string `json:"apiVersion"`
BuildID string `json:"buildId"`
RouteID string `json:"routeId"`
Props any `json:"props"`
// RenderNow is the UTC RFC3339Nano instant used for render-snapshot Date
// projections in the Go plan. The browser must use this same instant on
// first paint (via Vite rewrites), not new Date() at hydrate time.
RenderNow string `json:"renderNow,omitempty"`
// RenderLocale is the document language used for first paint. Locale-sensitive
// strings (Intl.DateTimeFormat, etc.) are not portable Date intrinsics —
// format them in the Go loader and pass as props. This field documents the
// server locale for diagnostics and future Intl work.
RenderLocale string `json:"renderLocale,omitempty"`
}
type Input ¶
type Input struct {
PublicOrigin string
Indexable bool
Metadata gb.Metadata
Body BodyHTML
Hydration HydrationData
Styles []Asset
ModulePreloads []Asset
Scripts []Asset
Nonce string
// TraceParent and TraceState are the document request's W3C context.
// When valid they are copied into <meta> tags so browser fetches can
// continue the page request instead of opening a new root.
TraceParent string
TraceState string
}
Click to show internal directories.
Click to hide internal directories.