Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Examples:
- After a coherent batch is committed locally, push it to `origin/dev`.
- Open a pull request from `dev` to `main` for review and release tracking.
- Merge the pull request into `main` only after the release candidate is ready.
- If pull request merge permission is unavailable, stop at the PR step and hand the PR back to a maintainer.
- Do not merge `dev` into `main` locally as a substitute for the GitHub pull request flow.
- Do not push release changes directly to `origin/main`.

## Documentation Map
Expand Down
29 changes: 28 additions & 1 deletion apps/api/src/lib/contributors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { asc, count, desc, eq, inArray } from 'drizzle-orm';
import { asc, count, desc, eq, inArray, sql } from 'drizzle-orm';

import { contributorRoleBindings, contributorRoles, contributors } from '@rebase/db';
import type {
Expand Down Expand Up @@ -341,3 +341,30 @@ export const listPublicContributorGroups = async () => {
contributors: contributorsByRole.get(role.id) ?? [],
}));
};

export const listRandomPublicContributors = async (limit = 10) => {
const db = getDb();
const contributorRows =
limit > 0
? await db
.select({
slug: contributors.slug,
name: contributors.name,
avatarAssetId: contributors.avatarAssetId,
avatarSeed: contributors.avatarSeed,
})
.from(contributors)
.where(eq(contributors.status, 'published'))
.orderBy(sql`random()`)
.limit(limit)
: [];

const avatarUrls = await listPublicAssetUrlsById(contributorRows.map((contributor) => contributor.avatarAssetId));

return contributorRows.map((contributor) => ({
slug: contributor.slug,
name: contributor.name,
avatarUrl: contributor.avatarAssetId ? avatarUrls.get(contributor.avatarAssetId) : undefined,
avatarSeed: contributor.avatarSeed,
}));
};
6 changes: 4 additions & 2 deletions apps/api/src/routes/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Hono } from 'hono';

import { ok } from '../lib/http.js';
import { getPublicArticleBySlug, listPublicArticles } from '../lib/articles.js';
import { listPublicContributorGroups } from '../lib/contributors.js';
import { listPublicContributorGroups, listRandomPublicContributors } from '../lib/contributors.js';
import { getPublicEventBySlug, listPublicEvents } from '../lib/events.js';
import {
getGeekDailySearchDocuments,
Expand Down Expand Up @@ -34,13 +34,14 @@ publicRoutes.get('/site-config', async (c) => c.json(ok(await getPublicSiteConfi
publicRoutes.get('/about', async (c) => c.json(ok(await getPublicAboutPage())));

publicRoutes.get('/home', async (c) => {
const [site, about, articles, jobs, events, geekdaily] = await Promise.all([
const [site, about, articles, jobs, events, geekdaily, featuredContributors] = await Promise.all([
getPublicSiteConfig(),
getPublicAboutPage(),
listPublicArticles(),
listPublicJobs(),
listPublicEvents(),
listPublicGeekDailyEpisodes(3),
listRandomPublicContributors(10),
]);

const recentArticles = sortByPublishedAtDesc(articles).slice(0, 3);
Expand Down Expand Up @@ -90,6 +91,7 @@ publicRoutes.get('/home', async (c) => {
recentJobs,
upcomingEvents,
recentGeekDaily: geekdaily,
featuredContributors,
dynamicFeed,
}),
);
Expand Down
9 changes: 9 additions & 0 deletions apps/web/src/lib/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ interface ContributorGroupPayload {
contributors: Contributor[];
}

interface HomeContributorPreviewPayload {
slug: string;
name: string;
avatarUrl?: string;
avatarSeed: string;
}

interface PublicGeekDailyItemPayload {
title: string;
authorName: string;
Expand Down Expand Up @@ -67,6 +74,7 @@ interface HomeFeedPayload {
recentJobs: Job[];
upcomingEvents: Event[];
recentGeekDaily: PublicGeekDailyEpisodePayload[];
featuredContributors: HomeContributorPreviewPayload[];
dynamicFeed: Array<{
type: 'article' | 'job' | 'event' | 'geekdaily';
title: string;
Expand Down Expand Up @@ -245,6 +253,7 @@ export async function getHomeFeed() {
latestEvents: payload.upcomingEvents,
latestGeekDaily: payload.latestGeekDaily ? mapGeekDailyEpisode(payload.latestGeekDaily) : undefined,
recentGeekDaily: payload.recentGeekDaily.map(mapGeekDailyEpisode),
featuredContributors: payload.featuredContributors,
dynamicFeed: payload.dynamicFeed.map((item) => {
if (item.type !== 'event' || !item.publishedAt || !item.href.startsWith('/events/')) {
return item;
Expand Down
Loading
Loading