PageSourceSearch

https://www.beritaharian.sg/web2-assets/useChartBeatRecommendedArticles-B59sxKkV.js

js beritaharian.sg collected 2026-09-24 09:10:36 UTC 2,174 bytes, 2 lines download raw bytes

1import{N as e,z as t}from"./chunk-KS7C4IRE-Bdf4_ABx.js";import{r as n}from"./getErrorMessage-0c2CBjH-.js";import{t as r}from"./Logger-BzWcw4bj.js";var i={endpoint:`https://recommendations.chartbeat.net/publishing/recommendations/v2/device`,host:`beritaharian.sg`,path:`beritaharian.sg/`,limit:`20`,excludeSections:`miscellaneous,podcasts,videos`,apiUrl:`http://api.chartbeat.com/live/toppages/v3/`,articlesCount:20,cacheTtlSeconds:3600,cacheKey:`CHARTBEAT_POPULAR_ARTICLES`};async function a(){try{let e=new URL(i.endpoint);e.searchParams.set(`host`,i.host),e.searchParams.set(`path`,i.path),e.searchParams.set(`limit`,i.limit),e.searchParams.set(`exclude_sections`,i.excludeSections);let t=await fetch(e.toString(),{method:`GET`,cache:`no-store`});if(!t.ok)throw Error(`HTTP error fetching ChartBeat recommendations! Status: ${t.status}`);let n=await t.json(),a=t.headers.get(`x-charbeat-recommendations-placeholder`)===`true`||t.headers.get(`cache-control`)===`no-store`;return a&&r.debug(`ChartBeat returned placeholder recommendations - tailored results coming soon`,{cacheControl:t.headers.get(`cache-control`),isPlaceholder:a}),{articlePaths:n.data.map(({path:e})=>e.replace(`beritaharian.sg`,``)),isPlaceholder:a}}catch(e){return r.error(`Failed to fetch ChartBeat recommendations from direct API`,{error:e.message}),{articlePaths:[],isPlaceholder:!1}}}async function o(e){try{return(await n(`get-articles-by-paths`,`POST`,{articlePaths:e})).data||[]}catch(t){return r.error(`Failed to fetch articles by paths for chart beat recommendations`,{error:t.message,articlePaths:e}),[]}}var s=t(e(),1);function c({enabled:e=!0,initialArticles:t=[]}){let[n,r]=(0,s.useState)(t),[i,c]=(0,s.useState)(!1),[l,u]=(0,s.useState)(!1),[d,f]=(0,s.useState)(!1),p=(0,s.useCallback)(async()=>{c(!0),u(!1),f(!1);try{let{articlePaths:e,isPlaceholder:t}=await a();if(f(t),e.length===0)return;let n=await o(e);r(n)}catch(e){console.error(`Failed to fetch recommended articles`,e),u(!0)}finally{c(!1)}},[]);return(0,s.useEffect)(()=>{e&&p()},[e,p]),{articles:n,loading:i,error:l,isPlaceholder:d,refetch:p}}export{c as t};
2//# sourceMappingURL=useChartBeatRecommendedArticles-B59sxKkV.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.