MCPcopy
hub / github.com/unpkg/unpkg / renderPage

Function renderPage

packages/unpkg-www/src/request-handler.tsx:311–327  ·  view source on GitHub ↗
(env: Env, node: VNode, init?: ResponseInit)

Source from the content-addressed store, hash-verified

309}
310
311async function renderPage(env: Env, node: VNode, init?: ResponseInit): Promise<Response> {
312 let assetsManifest = await loadAssetsManifest(env);
313
314 let html = render(
315 <AssetsContext.Provider value={assetsManifest}>
316 <Document origin={env.ORIGIN}>{node}</Document>
317 </AssetsContext.Provider>
318 );
319
320 return new Response("<!DOCTYPE html>" + html, {
321 ...init,
322 headers: {
323 "Content-Type": "text/html",
324 ...init?.headers,
325 },
326 });
327}
328
329function filesPathname(packageName: string, version?: string, filename?: string): string {
330 // The /files prefix is not needed for the root of the file browser.

Callers 1

handleRequestFunction · 0.70

Calls 1

loadAssetsManifestFunction · 0.90

Tested by

no test coverage detected