Documentation
¶
Index ¶
- func LookupInLaneWithDefaultFallback(idx *content.PageIndex, relPermalink string, page *engine.Page, ...) *engine.Page
- type CheckResult
- type LinkKind
- type PageLookup
- type ParsedDest
- type Renderer
- func (r *Renderer) DrainPendingAnchors() []links.PendingAnchorCheck
- func (r *Renderer) DrainRecordedRefs() []links.LinkRef
- func (r *Renderer) RegisterFuncs(reg gmrenderer.NodeRendererFuncRegisterer)
- func (r *Renderer) Reset()
- func (r *Renderer) ResolveHref(href string) (resolvedURL string)
- func (r *Renderer) SetPage(page *engine.Page)
- type ResolveContext
- type ResolveResult
- type URLResolverFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LookupInLaneWithDefaultFallback ¶ added in v1.0.0
func LookupInLaneWithDefaultFallback(idx *content.PageIndex, relPermalink string, page *engine.Page, resolver *engine.URLResolver) *engine.Page
LookupInLaneWithDefaultFallback resolves relPermalink in the page's own (lang, version) lane, falling back to the resolver's default language. Exported so build-side page-cache staleness verification reproduces resolveSiteAbsolute's exact lookup order without risking drift.
Types ¶
type CheckResult ¶ added in v1.0.0
type CheckResult struct {
Status links.LinkStatus
TargetPermalink string
HasFragment bool
}
CheckResult holds the outcome of checking whether an href resolves.
func CheckHref ¶ added in v1.0.0
func CheckHref(href string, page *engine.Page, ctx ResolveContext, idx *content.PageIndex, resolver *engine.URLResolver, siteRootEscapePrefix string) CheckResult
CheckHref determines whether href resolves in the context of page, using the same dispatch as Renderer.ResolveHref but without side effects (no LinkGraph recording, no pending-anchor accumulation). The caller is responsible for anchor validation via PageIndex.HasHeading when HasFragment is true.
idx is needed for site-absolute lookups via LookupInLaneWithDefaultFallback; ctx.PageIndex is used for lane-aware resolution of relative/content-root links.
type LinkKind ¶
type LinkKind int
LinkKind classifies a Markdown link destination.
const ( LinkExternal LinkKind = iota // http://, https://, //, mailto:, tel: LinkRelative // ./ or ../ LinkContentRoot // leading / (within collection) LinkAnchorOnly // starts with # LinkAmbiguous // bare name — rejected as ambiguous LinkSiteRoot // configured escape prefix (e.g. site:/x) — site-root, lane-free )
type PageLookup ¶
PageLookup is the interface the resolver needs from PageIndex.
type ParsedDest ¶
type ParsedDest struct {
Kind LinkKind
Path string // cleaned path, .md/.mdx extension stripped
Fragment string // without '#'
Query string // without '?'
Raw string // original href as written
}
ParsedDest is a classified, cleaned link destination.
func ClassifyDest ¶
func ClassifyDest(href string) ParsedDest
ClassifyDest parses a raw Markdown link destination into its parts and classifies it. Leading-/ paths are treated as content-root references unless they have a non-markdown file extension (e.g. .png, .css), in which case they pass through as external static assets.
type Renderer ¶
type Renderer struct {
CurrentPage *engine.Page
PageIndex *content.PageIndex
URLResolver *engine.URLResolver
LinkGraph *links.LinkGraph
// Collections is the per-build collection registry, used to detect when a
// link target lives in an unversioned collection (cross-dimension resolution).
Collections map[string]*engine.Collection
// SiteRootEscapePrefix is the configured prefix (e.g. "site:") that routes a
// link to the site root, bypassing collection/lane logic. Empty disables it.
SiteRootEscapePrefix string
PendingAnchors []links.PendingAnchorCheck
// RecordedRefs buffers a per-render copy of every ref written to LinkGraph,
// so the build layer can persist the page's resolution snapshot in the page
// cache and replay it on cache hits.
RecordedRefs []links.LinkRef
}
Renderer is a Goldmark node renderer for ast.KindLink that resolves internal links through the page index and URL resolver. External links pass through.
The CurrentPage, PageIndex, and URLResolver fields are swapped before each page render (same pattern as imagerender.Renderer.Lookup).
func NewRenderer ¶
func NewRenderer() *Renderer
NewRenderer creates a link renderer with no page context. Context must be set via SetPage before rendering.
func (*Renderer) DrainPendingAnchors ¶
func (r *Renderer) DrainPendingAnchors() []links.PendingAnchorCheck
DrainPendingAnchors returns and clears collected anchor checks.
func (*Renderer) DrainRecordedRefs ¶ added in v1.0.0
DrainRecordedRefs returns and clears the per-render link ref snapshot.
func (*Renderer) RegisterFuncs ¶
func (r *Renderer) RegisterFuncs(reg gmrenderer.NodeRendererFuncRegisterer)
RegisterFuncs registers the renderer for ast.KindLink.
func (*Renderer) Reset ¶
func (r *Renderer) Reset()
Reset clears accumulated state between page renders.
func (*Renderer) ResolveHref ¶
ResolveHref classifies, resolves, records in the link graph, and handles pending anchors for a given href. Returns the resolved URL. Card/button extension renderers call this to share the same resolution infrastructure.
type ResolveContext ¶
type ResolveContext struct {
PageIndex PageLookup
URLResolver URLResolverFunc
Collections map[string]*engine.Collection
}
ResolveContext carries the per-build dependencies the resolver needs. Collections is nil-safe: a nil map falls back to same-lane resolution (the current page's version), preserving behavior for callers that don't supply it.
type ResolveResult ¶
type ResolveResult struct {
URL string // final resolved URL (empty if not found)
TargetPermalink string // target page's Permalink (for anchor validation)
Found bool
}
ResolveResult holds the outcome of resolving an internal link.
func ResolveInternalLink ¶
func ResolveInternalLink( dest ParsedDest, currentPage *engine.Page, ctx ResolveContext, ) ResolveResult
ResolveInternalLink resolves a parsed destination in the current page's lane, returning the final URL via the URL resolver. External, anchor-only, and site-root links short-circuit without an index lookup.
type URLResolverFunc ¶
URLResolverFunc is the URL resolver signature needed by the link resolver.