Skip to content

API

ogygia/content/server

The wire layer — remotes over collections and sites.

On this page

Auto-generated from the package’s own .d.ts on every build — signatures, JSDoc, and examples straight from the source.

import { … } from 'ogygia/content/server';

Exports remotes · withRemotes · WithRemotes · ContentMode · GetRemote · ListRemote · SiteRemotes

remotes

function

Mint a site's Kit remotes. base is the mount prefix (baked into nav hrefs and search hit hrefs); default '' (root mount).

modes picks each remote's wire mode (the same dial as withRemotes): prerender (default for nav + doc — static payloads, required when the awaiting pages prerender; dynamic: true keeps runtime resolution for uncovered args) or query (per-request compute — a preview deployment, a context-gated site). search is inherently per-request and always query.

function remotes(site: Site, opts?: {
  base?: string;
  modes?: {
    nav?: ContentMode;
    page?: ContentMode;
  };
}): SiteRemotes;

withRemotes

function

Augment a browser-safe collection with its Kit remotes (and keep its read methods). Server-only (imports $app/server) — call it from a .remote.ts.

function withRemotes<T extends Record<string, unknown> = Record<string, unknown>>(handle: unknown): WithRemotes<T>;

WithRemotes

interface

The server-side handle withRemotes() returns: the collection's read paths + its remotes.

interface WithRemotes<T extends Record<string, unknown>> {/*…*/}

WithRemotes.refs

refs(): Promise<ContentRef<T>[]>;

WithRemotes.get

get(id: string): Promise<Entry<T> | null>;

WithRemotes.list

Prerendered/query remote over the corpus refs (wire-safe metadata).

list<Out = {
    id: string;
    data: T;
  }>(options?: RefsOptions<T, Out>): ListRemote<Out>;

WithRemotes.live

live: {
    list<Out = {
      id: string;
      data: T;
    }>(options?: LiveRefsOptions<T, Out>): ListRemote<Out>;
    get<Out = {
      id: string;
      data: T;
    } | null>(options?: LiveGetOptions<T, Out>): GetRemote<Out>;
  };

ContentMode

type

type ContentMode = 'prerender' | 'query';

GetRemote

type

type GetRemote<Out> = (id: string) => Promise<Out>;

ListRemote

type

Return types for the minted remotes (the callable shape consumers use; cast for extra methods).

type ListRemote<Out> = () => Promise<Out[]>;

SiteRemotes

type

type SiteRemotes = {
  nav: (slug?: string) => Promise<NavTree>;
  meta: (slug?: string) => Promise<SiteMeta>;
  search: (q: string) => Promise<SearchHit[]>;
  page: (slug: string) => Promise<PageView | null>;
};