strip tags hinzugefügt
This commit is contained in:
parent
814694c97e
commit
6568ffb45c
@ -1,13 +1,3 @@
|
||||
/* global Module, MMM-Wordpress */
|
||||
|
||||
/* Magic Mirror
|
||||
* Module: MMM-Wordpress
|
||||
*
|
||||
* By Tobias Buss
|
||||
* MIT Licensed.
|
||||
*/
|
||||
|
||||
|
||||
Module.register('MMM-Wordpress', {
|
||||
defaults: {
|
||||
updateInterval: 600000, // 10 minutes
|
||||
@ -26,12 +16,11 @@ Module.register('MMM-Wordpress', {
|
||||
|
||||
getPosts: function() {
|
||||
const url = this.config.url;
|
||||
const posts = this.config.posts;
|
||||
const numberOfPosts = this.config.numberOfPosts;
|
||||
|
||||
const request = require('request');
|
||||
|
||||
request.get(`${url}/wp-json/wp/v2/${posts}?per_page=${numberOfPosts}`, (error, response, body) => {
|
||||
request.get(`${url}/wp-json/wp/v2/posts?per_page=${numberOfPosts}`, (error, response, body) => {
|
||||
if (!error && response.statusCode == 200) {
|
||||
this.posts = JSON.parse(body);
|
||||
this.updateDom();
|
||||
@ -47,15 +36,19 @@ Module.register('MMM-Wordpress', {
|
||||
for (let i = 0; i < posts.length; i++) {
|
||||
const post = posts[i];
|
||||
const postElement = document.createElement('div');
|
||||
postElement.innerHTML = `<h2>${post.title.rendered}</h2><p>${post.excerpt.rendered}</p>`;
|
||||
postElement.innerHTML = `<h2>${this.stripTags(post.title.rendered)}</h2><p>${this.stripTags(post.excerpt.rendered)}</p>`;
|
||||
wrapper.appendChild(postElement);
|
||||
}
|
||||
} else {
|
||||
wrapper.innerHTML = 'No posts found';
|
||||
wrapper.innerHTML = 'Keine Beiträge gefunden';
|
||||
}
|
||||
|
||||
return wrapper;
|
||||
},
|
||||
|
||||
stripTags: function(html) {
|
||||
const doc = new DOMParser().parseFromString(html, 'text/html');
|
||||
return doc.body.textContent || "";
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user