Skip to content

Commit 6dd0dfb

Browse files
committed
feat: enhance ZoteroFeed component with top-level item fetching and client-side filtering
1 parent fd4f672 commit 6dd0dfb

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

app/components/ZoteroFeed.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as React from "react";
44
type ZoteroItem = {
55
key: string;
66
data?: {
7+
itemType?: string;
78
title?: string;
89
url?: string;
910
date?: string;
@@ -26,11 +27,18 @@ export function ZoteroFeed({
2627

2728
React.useEffect(() => {
2829
const controller = new AbortController();
29-
const url = `https://api.zotero.org/groups/${groupId}/items?format=json&limit=${limit}`;
30+
// Fetch only top-level items; exclude children implicitly. We will filter
31+
// attachments/notes on the client for extra safety.
32+
const url = `https://api.zotero.org/groups/${groupId}/items/top?format=json&limit=${limit}&sort=date&direction=desc`;
3033
fetch(url, { signal: controller.signal })
3134
.then(async (r) => {
3235
if (!r.ok) throw new Error(`${r.status} ${r.statusText}`);
3336
const data: ZoteroItem[] = await r.json();
37+
// Debug: inspect fetched items in the browser console
38+
if (typeof window !== "undefined") {
39+
// Expose for manual inspection in DevTools: window.__zotero
40+
(window as any).__zotero = data;
41+
}
3442
setItems(data);
3543
})
3644
.catch((e: unknown) => {
@@ -83,6 +91,12 @@ export function ZoteroFeed({
8391
{items && (
8492
<ul className="grid grid-cols-1 md:grid-cols-2 gap-3">
8593
{items
94+
// Guard against attachments/notes even if server-side filter changes
95+
.filter(
96+
(it) =>
97+
it.data?.itemType !== "attachment" &&
98+
it.data?.itemType !== "note",
99+
)
86100
.filter((it) => it.data?.title && it.data.title.trim() !== "")
87101
.map((it) => {
88102
const d = it.data ?? {};

0 commit comments

Comments
 (0)