Update top posts and upvote to pass/get title

This commit is contained in:
Alex Selimov 2026-08-03 23:38:33 -04:00
parent 92ea370e40
commit 9a66205d80
2 changed files with 8 additions and 15 deletions

View file

@ -14,27 +14,16 @@
for (post of data) {
const postUrl = post.slug.replace("posts-", "");
const pageUrl = `/posts/${postUrl}`;
const title = post.title;
try {
const pageResponse = await fetch(pageUrl);
const html = await pageResponse.text();
const doc = new DOMParser().parseFromString(html, "text/html");
const title =
doc.querySelector('meta[property="og:title"]')?.content ||
doc.title ||
slug;
const li = document.createElement("li");
const li = document.createElement("li");
li.innerHTML = `
li.innerHTML = `
<a href="/posts/${postUrl}">
${title}
</a>
`;
ul.appendChild(li);
} catch (err) {
console.error(err);
}
ul.appendChild(li);
}
})();