File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import * as React from "react";
44type 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 ?? { } ;
You can’t perform that action at this time.
0 commit comments