document

package
v0.1.0-alpha.138 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func NormalizeTraceParent(value string) string

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

func NormalizeTraceState(value string) string

NormalizeTraceState returns a W3C tracestate value, or empty when it is missing or not safe to copy into HTML.

func Render

func Render(writer io.Writer, input Input) error

Types

type Asset

type Asset struct {
	URL       string
	Integrity string
}

type BodyHTML

type BodyHTML string

type HydrationData

type HydrationData struct {
	DeploymentRevision string            `json:"deploymentRevision,omitempty"`
	PublicConfig       map[string]string `json:"publicConfig,omitempty"`
	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
}

Jump to

Keyboard shortcuts

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