DataGate.ch Site Map

All published content — organized by category

Loading posts from WordPress…

fetch(‚https://data-gate.ch/wp-json/wp/v2/posts?per_page=100&orderby=date&order=desc&_fields=id,date,title,slug,link‘)
.then(function(r){return r.json()})
.then(function(posts){
document.getElementById(‚loading‘).style.display=’none‘;
document.getElementById(‚content‘).style.display=’block‘;

// Stats
var total=posts.length;
var dates=posts.map(function(p){return p.date});
var oldest=(dates[dates.length-1]||“).substring(0,10);
var newest=(dates[0]||“).substring(0,10);
document.getElementById(’stats‘).innerHTML=

‚+total+‘
Total Posts

‚+

‚+newest+‘
Latest Post

‚+

‚+oldest+‘
First Post

‚;

// Group by month
var months={};
posts.forEach(function(p){
var m=p.date.substring(0,7);
if(!months[m])months[m]=[];
months[m].push(p);
});

var html=“;
Object.keys(months).sort().reverse().forEach(function(m){
var monthName=new Date(m+‘-01′).toLocaleDateString(‚en-US‘,{year:’numeric‘,month:’long‘});
html+=‘

‚;
html+=‘

‚+monthName+‘ (‚+months[m].length+‘ posts)

‚;
html+=‘

‚;
months[m].forEach(function(p){
var d=p.date.substring(8,10);
html+=‘‚;
html+=‘‚+d+‘‚;
html+=‘‚+p.title.rendered+‘‚;
html+=‘/’+p.slug+‘‚;
html+=‘
‚;
});
html+=‘

‚;
});
document.getElementById(‚posts‘).innerHTML=html;
})
.catch(function(e){
document.getElementById(‚loading‘).style.display=’none‘;
document.getElementById(‚error‘).style.display=’block‘;
document.getElementById(‚error‘).textContent=’Error loading posts: ‚+e.message;
});

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert