(function(){function isBlog(){var p=location.pathname;if(p.length>1&&p.charAt(p.length-1)==='/'){p=p.slice(0,-1)}return p==='/blog'}function make(tag,cls){var e=document.createElement(tag);if(cls){e.className=cls}return e}function decode(s){var t=document.createElement('textarea');t.innerHTML=s||'';return t.value}function fmt(d){try{return new Date(d).toLocaleDateString('en-US',{year:'numeric',month:'short',day:'numeric'})}catch(e){return''}}function render(posts){if(!isBlog()||document.querySelector('.kexin-blog-index')){return}var first=document.querySelector('article');if(!first||!posts||!posts.length){return}var sec=make('section','kexin-blog-index');var inner=make('div','kexin-blog-index-inner');var head=make('div','kexin-blog-index-head');var copy=make('div','');var h=make('h2','');h.textContent='All Blog Articles';var p=make('p','');p.textContent='Browse packaging guides, product tips and factory insights in one place.';copy.appendChild(h);copy.appendChild(p);var input=make('input','kexin-blog-search');input.type='search';input.placeholder='Search blog articles';head.appendChild(copy);head.appendChild(input);var ul=make('ul','kexin-blog-list');posts.forEach(function(post){var li=make('li','kexin-blog-item');var a=make('a','');a.href=post.link||'#';a.textContent=decode(post.title&&post.title.rendered);var date=make('span','kexin-blog-date');date.textContent=fmt(post.date);li.appendChild(a);li.appendChild(date);ul.appendChild(li)});var empty=make('div','kexin-blog-empty');empty.textContent='No matching articles found.';inner.appendChild(head);inner.appendChild(ul);inner.appendChild(empty);sec.appendChild(inner);first.parentNode.insertBefore(sec,first);var items=[].slice.call(sec.querySelectorAll('.kexin-blog-item'));input.addEventListener('input',function(){var q=this.value.toLowerCase().trim();var shown=0;items.forEach(function(li){var hit=li.textContent.toLowerCase().indexOf(q)>-1;li.style.display=hit?'':'none';if(hit){shown++}});empty.style.display=shown?'none':'block'})}function load(){if(!isBlog()){return}var x=new XMLHttpRequest();x.open('GET','/wp-json/wp/v2/posts?per_page=100&_fields=date,link,title');x.onload=function(){try{render(JSON.parse(x.responseText))}catch(e){}};x.send()}if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',load)}else{load()}})();
Skip to content
Kexin Packaging transformed our product presentation with exceptional packaging solutions. Highly recommended!