<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sitemap</title>
<style>
.new { color: red; }
.label { font-weight: bold; margin-top: 20px; }
</style>
</head>
<body>
<h1>Selamat Datang Di Website Kami</h1>
<div id="sitemap">
<!-- Sitemap akan diisi oleh JavaScript -->
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
const feedUrl = 'https://www.prakerin.misntv.com/feeds/posts/default?alt=json';
fetch(feedUrl)
.then(response => response.json())
.then(data => {
const entries = data.feed.entry;
const now = new Date();
const sitemap = document.getElementById('sitemap');
const labelsMap = {};
entries.forEach(entry => {
const title = entry.title.$t;
const link = entry.link.find(el => el.rel === 'alternate').href;
const published = new Date(entry.published.$t);
const labels = entry.category ? entry.category.map(cat => cat.term) : ['Uncategorized'];
labels.forEach(label => {
if (!labelsMap[label]) {
labelsMap[label] = [];
}
const timeDiff = Math.abs(now - published);
const diffDays = Math.ceil(timeDiff / (1000 * 60 * 60 * 24));
const isNew = diffDays <= 7;
labelsMap[label].push({
title,
link,
isNew
});
});
});
Object.keys(labelsMap).sort().forEach(label => {
const labelDiv = document.createElement('div');
labelDiv.className = 'label';
labelDiv.textContent = label;
sitemap.appendChild(labelDiv);
const ul = document.createElement('ul');
labelsMap[label].forEach(post => {
const li = document.createElement('li');
const a = document.createElement('a');
a.href = post.link;
a.textContent = post.title;
li.appendChild(a);
if (post.isNew) {
const span = document.createElement('span');
span.textContent = ' NEW';
span.className = 'new';
li.appendChild(span);
}
ul.appendChild(li);
});
sitemap.appendChild(ul);
});
})
.catch(error => console.error('Error fetching the feed:', error));
});
</script>
</body>
</html>