@ogygia/content · API
@ogygia/content/server
The wire layer, which provides remotes over collections and sites.
On this page
This page is generated from the package’s own .d.ts files on every build, so the signatures, descriptions and examples below always match the source.
Exports remotes · withRemotes · WithRemotes · ContentMode · GetRemote · ListRemote · SiteRemotes
import { … } from '@ogygia/content/server';remotes
function
Mint a site's Kit remotes: the browser-safe site() defines the site once, remotes(site) mints
its wire access (as withRemotes() does for a collection). It imports $app/server, so call it
from a .remote.ts.
base is the mount prefix (baked into nav hrefs and search hit hrefs); default '' (root
mount). nav and meta take a slug that names the dimensions() coordinate; none is the default
one. page crosses without the entry's server-only source reader, its body awaited (rendered).
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.
// docs.remote.ts
import { remotes } from '@ogygia/content/server';
import { docs } from './docs';
export const { nav, meta, search, page } = remotes(docs, { base: '/docs' });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
(it imports $app/server): call it from a .remote.ts.
// docs.remote.ts
import { withRemotes } from '@ogygia/content/server';
const r = withRemotes(docs);
export const docNav = r.list({ map: (e) => ({ id: e.id, title: e.data.title }) });
export const feed = r.live.list({ map });
export const oneLive = r.live.get({ map, notFound: null });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.
WithRemotes.refs
WithRemotes.get
WithRemotes.list
A remote over the corpus refs (wire-safe metadata). mode is 'prerender' for a static
source and 'query' for one that reads at request time (dynamic or live); a prerender is
Kit-dynamic unless dynamic: false.
WithRemotes.live
interface WithRemotes<T extends Record<string, unknown>> {/*…*/}refs(): Promise<ContentRef<T>[]>;get(id: string): Promise<Entry<T> | null>;list<Out = {
id: string;
data: T;
}>(options?: RefsOptions<T, Out>): ListRemote<Out>;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>;
};type ContentMode = "prerender" | "query";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[]>;type SiteRemotes = {
nav: (slug?: string) => Promise<NavTree>;
meta: (slug?: string) => Promise<SiteMeta>;
search: (q: string) => Promise<SearchHit[]>;
page: (slug: string) => Promise<PageView | null>;
};