contentviewer

package
v1.129.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package contentviewer embeds the public share viewer's frontend build: the code-split JavaScript chunks produced from ui/src/content-viewer-entry.tsx and the stylesheet compiled against them. The viewer renders every content type with the same React renderers as the authenticated portal.

The JavaScript is a chunk graph rather than a single bundle, and it is served as files instead of being inlined into the share page. A share of an 850-byte markdown document used to carry the whole renderer — the JSX transformer, CodeMirror, the diagram engine — because the build format collapsed every lazy() boundary back into one file (#1355). Now the page references the entry chunk and the browser fetches only what the asset's family needs, and caches it for the next share it opens.

The stylesheet stays inline: it is small once compiled against the viewer's own bundle, and inlining it keeps the page from blocking first paint on a second round trip.

Index

Constants

View Source
const AssetPathPrefix = "/portal/view/_assets/"

AssetPathPrefix is the URL prefix the viewer's chunks are served under. It matches the `base` in ui/vite.content-viewer.config.ts: vite bakes that value into the chunk-loading helper, so the two cannot drift without the dynamic imports 404ing.

Variables

CSS is the viewer's stylesheet, inlined into the share page. Empty when the frontend has not been built (e.g. CI's embed-clean).

Functions

func EntryURL added in v1.122.0

func EntryURL() string

EntryURL returns the absolute path the share page should load the viewer from, or "" when no bundle is embedded. A page rendered without a bundle still serves its metadata and its download link; only the rendered preview is missing, which is the same degradation the un-built bundle produced before.

func Handler added in v1.122.0

func Handler() http.Handler

Handler serves the viewer's chunks under AssetPathPrefix.

The share page is reachable without signing in, so this is too — it is the code that renders the page, and gating it would leave every public share blank. Nothing here is share-specific: the same bytes are served whatever token was opened, and no share is looked up, so the caller mounts it outside the share access gate.

Types

This section is empty.

Jump to

Keyboard shortcuts

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