Skip to content
Source
Sign inSign up
samwillis/hackernews-realtime
Open History to see the last commit

fixture.ts

25 lines1015 Bytes

1import { PAGE_SIZE, type Feed, type Story } from "./types";
2const titles = [
3 ["Show HN: A tiny database that fits in your pocket", "https://neon.com"],
4 ["The quiet art of making software last", "https://example.com/software"],
5 ["Ask HN: What are you working on?", null],
6 ["A visual introduction to how Postgres works", "https://www.postgresql.org"],
7 [
8 "Building a better web, one small page at a time",
9 "https://example.com/web",
10 ],
11];
12export function fixture(feed: Feed, page: number): Story[] {
13 return Array.from({ length: PAGE_SIZE }, (_, index) => ({
14 item_id: (feed === "top" ? 1000 : 2000) + (page - 1) * PAGE_SIZE + index,
15 rank: (page - 1) * PAGE_SIZE + index + 1,
16 title: titles[index % titles.length][0]!,
17 url: titles[index % titles.length][1],
18 author: ["dang", "sama", "pg", "tptacek"][index % 4],
19 created: 1791806400 - index * 600,
20 score: 245 - index * 5,
21 comments: 60 - index,
22 type: "story",
23 committed_at: "2026-10-12T08:00:00.000Z",
24 }));