MCPcopy
hub / github.com/Innei/Shiro / fetch

Function fetch

src/components/ui/link-card/LinkCard.tsx:467–515  ·  view source on GitHub ↗
(id, setCardInfo, setFullUrl)

Source from the content-addressed store, hash-verified

465 return canParsedTypes.includes(type) && realId.length > 0
466 },
467 async fetch(id, setCardInfo, setFullUrl) {
468 const [type, realId] = id.split('/')
469
470 setCardInfo({
471 classNames: { cardRoot: '!w-full' },
472 })
473 const json = await fetch(`/api/tmdb/${type}/${realId}?language=zh-CN`)
474 .then((r) => r.json())
475 .catch((err) => {
476 console.error('Error fetching TMDB data:', err)
477 throw err
478 })
479
480 const title = type === 'tv' ? json.name : json.title
481 const originalTitle =
482 type === 'tv' ? json.original_name : json.original_title
483 setCardInfo({
484 title: (
485 <span className="flex flex-wrap items-end gap-2">
486 <span>{title}</span>
487 {title !== originalTitle && (
488 <span className="text-sm opacity-70">({originalTitle})</span>
489 )}
490 <span className="inline-flex shrink-0 items-center gap-1 self-center text-xs text-orange-400 dark:text-yellow-500">
491 <MingcuteStarHalfFill />
492 <span className="font-sans font-medium">
493 {json.vote_average > 0 && json.vote_average.toFixed(1)}
494 </span>
495 </span>
496 </span>
497 ),
498 desc: (
499 <span className="line-clamp-none overflow-visible whitespace-pre-wrap">
500 {json.overview}
501 </span>
502 ),
503 image: `https://image.tmdb.org/t/p/w500${json.poster_path}`,
504 color: uniqolor(json.name, {
505 saturation: [30, 35],
506 lightness: [60, 70],
507 }).color,
508
509 classNames: {
510 image: 'self-start !h-[75px] !w-[50px]',
511 cardRoot: '!w-full !flex-row-reverse',
512 },
513 })
514 json.homepage && setFullUrl(json.homepage)
515 },
516}
517
518const fetchLeetCodeQuestionData: FetchObject = {

Callers 15

fetchJsonDataFunction · 0.85
SiteOwnerAvatarFunction · 0.85
AISummaryFunction · 0.85
XLogSummaryFunction · 0.85
fetchDataFunction · 0.85
fetchHitokotoFunction · 0.85
getCrossbellNoteDataMethod · 0.85
getJinRiShiCiOneFunction · 0.85
fetchHitokotoFunction · 0.85
LinkCard.tsxFile · 0.85

Calls 2

jsonMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected