import { fetchEntities } from '#/src/entities.js';

export async function onBeforeRender(pageContext) {
	const networks = await fetchEntities(pageContext.urlParsed.search.q
		? { query: pageContext.urlParsed.search.q }
		: { type: 'primary' }, {
		restriction: pageContext.geo.restriction,
	});

	return {
		pageContext: {
			title: 'Channels',
			pageProps: {
				networks,
			},
		},
	};
}
