aggiunta sezione per articoli in evidenza
This commit is contained in:
parent
ca4cab59f7
commit
357d303bfb
27
counters.js
27
counters.js
|
@ -169,6 +169,31 @@ function counters() {
|
||||||
})
|
})
|
||||||
.catch(err => console.error(err));
|
.catch(err => console.error(err));
|
||||||
|
|
||||||
|
fetch("https://golem.linux.it/wp/wp-json/wp/v2/posts?sticky=true")
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(json => {
|
||||||
|
let article = document.getElementById("wp-featured-posts");
|
||||||
|
|
||||||
|
if (json.length == 0) {
|
||||||
|
let text = document.createTextNode("Nessun articolo in evidenza");
|
||||||
|
article.appendChild(text);
|
||||||
|
} else {
|
||||||
|
let post = json[0];
|
||||||
|
let a = document.createElement("a");
|
||||||
|
a.href = post.link;
|
||||||
|
a.appendChild(document.createTextNode(post.title.rendered));
|
||||||
|
article.appendChild(a);
|
||||||
|
let text = post.excerpt.rendered.replace(/<.*?>/g, '');
|
||||||
|
text = text.substr(0, text.indexOf('.') + 1);
|
||||||
|
text += ' [...]';
|
||||||
|
let textNode = document.createTextNode(text);
|
||||||
|
article.appendChild(document.createElement('br'));
|
||||||
|
article.appendChild(textNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
.catch(err => console.error(err));
|
||||||
|
|
||||||
fetch("https://golem.linux.it/wiki/api.php?action=query&list=recentchanges&rcprop=title&rclimit=50&format=json&origin=*")
|
fetch("https://golem.linux.it/wiki/api.php?action=query&list=recentchanges&rcprop=title&rclimit=50&format=json&origin=*")
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(json => {
|
.then(json => {
|
||||||
|
@ -193,8 +218,6 @@ function counters() {
|
||||||
})
|
})
|
||||||
.catch(function(error){console.log(error);});
|
.catch(function(error){console.log(error);});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fetch("https://golem.linux.it/wp/wp-json/wp/v2/posts")
|
fetch("https://golem.linux.it/wp/wp-json/wp/v2/posts")
|
||||||
.then(response => {
|
.then(response => {
|
||||||
let articles = response.headers.get("X-WP-Total");
|
let articles = response.headers.get("X-WP-Total");
|
||||||
|
|
|
@ -56,12 +56,16 @@
|
||||||
|
|
||||||
<section id="news" class="bg">
|
<section id="news" class="bg">
|
||||||
<h2>News</h2>
|
<h2>News</h2>
|
||||||
|
<div>
|
||||||
|
<h3>In evidenza</h3>
|
||||||
|
<ul id="wp-featured-posts"></ul>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h3>Calendario</h3>
|
<h3>Calendario</h3>
|
||||||
<ul id="zerocalcare-latest-events"></ul>
|
<ul id="zerocalcare-latest-events"></ul>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h3>Ultimi post</h3>
|
<h3>Ultimi articoli</h3>
|
||||||
<ul id="wp-latest-posts"></ul>
|
<ul id="wp-latest-posts"></ul>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|
Loading…
Reference in New Issue