.wp-block-query-title{font-weight:600 !important;} .tvn-latest-news-query{margin-top:20px !important;} .tvn-latest-news-item{align-items:flex-start !important;gap:10px !important;margin-bottom:20px !important;} .tvn-latest-news-item .tvn-latest-news-thumb, .tvn-latest-news-item .tvn-latest-news-thumb img{align-self:flex-start !important;margin-top:0 !important;} .tvn-latest-news-item .tvn-latest-news-thumb{width:98px !important;aspect-ratio:3/4 !important;height:auto !important;flex:0 0 98px !important;} .tvn-latest-news-item .tvn-latest-news-thumb img{width:100% !important;height:100% !important;aspect-ratio:3/4 !important;object-fit:cover !important;} .tvn-latest-news-query .tvn-latest-news-item-title, .tvn-latest-news-query .wp-block-post-title.tvn-latest-news-item-title{font-size:18px !important;font-weight:600 !important;line-height:normal !important;letter-spacing:normal !important;} .tvn-latest-news-divider{margin:0 !important;border:0 !important;height:1px !important;background-color:#e8ebee !important;opacity:1 !important;} .tvn-latest-news-query .wp-block-post-template > li:last-child .tvn-latest-news-divider{display:none !important;} .tvn-load-more-wrap{overflow-anchor:none;display:flex;justify-content:center;text-align:center;} .tvn-load-more-wrap .tvn-load-more-btn{display:inline-block;padding:8px 22px;cursor:pointer;line-height:1.3;text-decoration:none;user-select:none;-webkit-user-select:none;font-family:var(–wp–preset–font-family–montserrat),Montserrat,sans-serif;font-size:15px;color:#1f0196;background:#ffffff;border:1px solid #d9d9d9;} (function(){ var STEP=5; var list=document.querySelector(‘.tvn-latest-news-query .wp-block-post-template’); var btn=document.querySelector(‘.tvn-cat-more-btn’); if(!btn) return; var wrap=btn.parentNode; if(!list){ wrap.style.display=’none’; return; } var pending=[], done=false, busy=false, inflight=null, catPromise=null; var lis=[].slice.call(list.children); var loaded=lis.length; lis.slice(STEP).forEach(function(li){ list.removeChild(li); pending.push(li); }); function fmtDate(iso){var s=String(iso);var d=new Date(+s.substr(0,4),+s.substr(5,2)-1,+s.substr(8,2));var w=[‘Dom’,’Seg’,’Ter’,’Qua’,’Qui’,’Sex’,’Sáb’][d.getDay()];return w+’ ‘+s.substr(8,2)+’/’+s.substr(5,2)+’/’+s.substr(0,4)+’ – ‘+s.substr(11,2)+’h’+s.substr(14,2);} function build(p){ var li=document.createElement(‘li’); li.className=’wp-block-post post type-post’; var m=p._embedded&&p._embedded[‘wp:featuredmedia’]&&p._embedded[‘wp:featuredmedia’][0]; var img=”; if(m){ var sz=m.media_details&&m.media_details.sizes; var src=(sz&&sz.medium&&sz.medium.source_url)||m.source_url; if(src){ img=’
‘; } } li.innerHTML=’
‘+img+’

‘+p.title.rendered+’


‘; return li; } function getCat(){ if(catPromise) return catPromise; var segs=location.pathname.split(‘/’).filter(function(s){return s;}); var i=segs.indexOf(‘category’); var slug=null; if(i>-1){ var rest=segs.slice(i+1); var pg=rest.indexOf(‘page’); if(pg>-1) rest=rest.slice(0,pg); slug=rest[rest.length-1]; } if(!slug){ catPromise=Promise.resolve(null); return catPromise; } try{ slug=decodeURIComponent(slug); }catch(e){} catPromise=fetch(‘/wp-json/wp/v2/categories?slug=’+encodeURIComponent(slug)).then(function(r){return r.json();}).then(function(l){return (l&&l[0])?l[0].id:null;}).catch(function(){return null;}); return catPromise; } function update(){ wrap.style.display=(pending.length===0&&done)?’none’:”; } function ensure(){ if(done||pending.length>=STEP) return Promise.resolve(); if(inflight) return inflight; inflight=getCat().then(function(id){ if(!id){ done=true; return; } return fetch(‘/wp-json/wp/v2/posts?_embed=1&per_page=’+(STEP+1)+’&offset=’+loaded+’&categories=’+id).then(function(r){return r.json();}).then(function(posts){ if(!Array.isArray(posts)){ done=true; return; } posts.forEach(function(p){ pending.push(build(p)); }); loaded+=posts.length; if(posts.length<STEP+1) done=true; }); }).catch(function(){}).then(function(){ inflight=null; }); return inflight; } btn.addEventListener('click',function(e){ e.preventDefault(); if(busy) return; busy=true; ensure().then(function(){ pending.splice(0,STEP).forEach(function(el){ list.appendChild(el); }); busy=false; update(); ensure().then(update); }); }); ensure().then(update); })();