Skip to content

Commit fd4164c

Browse files
committed
Hard code photos
1 parent 7b8f42f commit fd4164c

File tree

7 files changed

+23
-14
lines changed

7 files changed

+23
-14
lines changed

packages/dev/s2-docs/pages/s2/home/app/Ideas.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@ import { Arrow, Arrows } from './Arrows';
1515
export function Ideas() {
1616
let {locale} = useLocale();
1717
let list = useAsyncList<Topic, number | null>({
18-
async load({signal, cursor}) {
19-
let page = cursor || 1;
20-
let res = await fetch(
21-
`https://api.unsplash.com/topics?page=${page}&per_page=30&client_id=AJuU-FPh11hn7RuumUllp4ppT8kgiLS7LtOHp_sp4nc`,
22-
{signal}
23-
);
24-
let items = (await res.json()).filter((topic: Topic) => !!topic.preview_photos);
25-
return {items, cursor: items.length ? page + 1 : null};
18+
async load() {
19+
let res = await import('./topics.json');
20+
let items = res.filter((topic: Topic) => !!topic.preview_photos);
21+
return {items};
2622
}
2723
});
2824

packages/dev/s2-docs/pages/s2/home/app/Photos.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,25 @@ import { useAsyncList } from 'react-stately';
88
import { useRef, useState } from 'react';
99
import { flushSync } from 'react-dom';
1010

11+
const pages = [
12+
() => import('./photos-1.json'),
13+
() => import('./photos-2.json'),
14+
() => import('./photos-3.json'),
15+
() => import('./photos-4.json')
16+
];
17+
1118
export function Photos(props: any) {
1219
let [layout, setLayout] = useState<'waterfall' | 'grid'>('waterfall');
1320
let {direction} = useLocale();
1421
let list = useAsyncList<any, number | null>({
15-
async load({signal, cursor, items}) {
22+
async load({cursor, items}) {
1623
let page = cursor || 1;
17-
let res = await fetch(
18-
`https://api.unsplash.com/topics/nature/photos?page=${page}&per_page=30&client_id=AJuU-FPh11hn7RuumUllp4ppT8kgiLS7LtOHp_sp4nc`,
19-
{signal}
20-
);
21-
let nextItems = await res.json();
24+
let next = pages[page - 1];
25+
if (!next) {
26+
return {items: []};
27+
}
28+
29+
let nextItems: any[] = await next();
2230
// Filter duplicates which might be returned by the API.
2331
let existingKeys = new Set(items.map(i => i.id));
2432
nextItems = nextItems.filter((i: any) => !existingKeys.has(i.id) && (i.description || i.alt_description));

packages/dev/s2-docs/pages/s2/home/app/photos-1.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

packages/dev/s2-docs/pages/s2/home/app/photos-2.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

packages/dev/s2-docs/pages/s2/home/app/photos-3.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

packages/dev/s2-docs/pages/s2/home/app/photos-4.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

packages/dev/s2-docs/pages/s2/home/app/topics.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)