Skip to content
GD Goenka Global School
News & Updates

Newsfeed

Stories, achievements, and moments from the GD Goenka Global School community.

Latest Updates

Newsfeed

Loading posts…

Experience GD Goenka Global School

We’d genuinely love to have you visit the campus and experience the learning community for yourself.

'; moreEl.style.display='none'; return; } var html = '
'; slice.forEach(function(post){ var img = getImg(post); var cat = getCatName(post); var date = fmtDate(post.date); var title= stripHtml(post.title.rendered); var exc = excerpt(post.excerpt.rendered, 120); var link = post.link; html += ''; /* image */ if(img){ html += '
'; } else { html += '
' +'' +'' +'' +'' +'
'; } /* body */ html += '
'; html += '
'; if(cat) html += ''+cat+''; if(date) html += ''+date+''; html += '
'; html += '
'+title+'
'; if(exc) html += '
'+exc+'
'; html += '
'; html += '
'; }); html += '
'; outEl.innerHTML = html; /* Load More */ var remaining = posts.length - slice.length; if(remaining > 0){ moreEl.style.display='block'; moreCtEl.textContent = remaining+' more post'+(remaining>1?'s':'')+' to load'; } else { moreEl.style.display='none'; } } /* ── TABS ── */ function buildTabs(){ var html = ''; cats.forEach(function(c){ html += ''; }); tabsEl.innerHTML = html; tabsEl.querySelectorAll('.nf-tab').forEach(function(btn){ btn.addEventListener('click',function(){ activeCat = parseInt(this.getAttribute('data-cat'),10); page = 0; tabsEl.querySelectorAll('.nf-tab').forEach(function(b){b.classList.remove('act')}); this.classList.add('act'); renderCards(); }); }); } /* ── FETCH ── */ function fetchCategories(){ return fetch(BASE+'/categories?per_page=50&hide_empty=true') .then(function(r){ return r.json(); }) .then(function(data){ cats = data .filter(function(c){ return c.name!=='Uncategorized' && c.count>0; }) .sort(function(a,b){ return b.count-a.count; }) .slice(0,6); /* max 6 tabs */ }) .catch(function(){ cats = []; }); } function fetchPosts(pageNum){ return fetch(BASE+'/posts?per_page='+BATCH+'&page='+pageNum+'&_embed=1&status=publish') .then(function(r){ var total = parseInt(r.headers.get('X-WP-TotalPages')||'1',10); return r.json().then(function(data){ return {posts:data,totalPages:total}; }); }); } function fetchAllPosts(){ /* Show spinner */ outEl.innerHTML = '
' +'' +'' +'

Loading posts…

'; /* Fetch categories and first batch in parallel */ Promise.all([fetchCategories(), fetchPosts(1)]) .then(function(results){ var data = results[1]; allPosts = data.posts||[]; var totalPages = data.totalPages||1; buildTabs(); renderCards(); /* Fetch remaining pages silently in background */ if(totalPages > 1){ var fetches = []; for(var p=2;p<=Math.min(totalPages,10);p++){ fetches.push(fetchPosts(p)); } Promise.all(fetches).then(function(pages){ pages.forEach(function(pg){ allPosts = allPosts.concat(pg.posts||[]); }); renderCards(); }).catch(function(){}); } }) .catch(function(){ outEl.innerHTML = '
' +'

Could not load posts. Please check your connection and try again.

' +'
'; }); } /* ── LOAD MORE ── */ if(moreBtnEl){ moreBtnEl.addEventListener('click',function(){ page++; renderCards(); /* Scroll smoothly to new cards */ setTimeout(function(){ var cards = outEl.querySelectorAll('.nf-card'); var idx = page * PER_PAGE; if(cards[idx]) cards[idx].scrollIntoView({behavior:'smooth',block:'start'}); },100); }); } /* ── INIT ── */ fetchAllPosts(); })();