function
withAdminLoader
Connect a generated Go loader reference to the Svelte component that displays its data.
Example
import { withAdminLoader } from '@riducms/plugin';
import { adminLoaders } from '../../generated/ridu.generated';
import PostSummary from './components/post-summary.svelte';
const report = {
path: 'post-report',
...withAdminLoader(adminLoaders['post-summary'], PostSummary)
};Arguments
| Argument | Type | Description |
|---|---|---|
loader | AdminLoader< | Reference from your generated adminLoaders object. Its key, query input, and result types come from Go. |
component | Component< | Svelte component accepting AdminLoaderProps<Data>, plus any props for its dashboard, route, or replacement-view location. |
Returns
The loader/component pair to spread into an admin registration. Ridu supplies the data when that registered component is shown.
{ loader: AdminLoader<never, unknown>; component: Component<Omit<Props, keyof AdminLoaderProps<unknown>> & AdminLoaderProps<unknown>>; }How it works
Spread the result into a dashboard, routes, or views registration. Keep the location-specific settings such as path, position, collection, and surface on that entry.
The component receives data, refresh, and refreshing. It does not need an initial fetch or a second copy of the loaded data.
This helper checks the component/data pairing at compile time. It does not execute the Go handler or register it on the server; add the Go definition to Config.Admin.Loaders first.
Full signature
function withAdminLoader<Input, Data, Props extends AdminLoaderProps<NoInfer<Data>>>(
loader: AdminLoader<Input, Data>,
component: Component<Props>,
): {
loader: AdminLoader<never, unknown>
component: Component<Omit<Props, keyof AdminLoaderProps<unknown>> & AdminLoaderProps<unknown>>
}Related types
AdminLoaderPropsProps supplied to a component paired with a Go admin loader.