Новые изменения в проект

This commit is contained in:
Web-serfer 2026-04-28 02:09:18 +05:00
parent 38bf5d7dcf
commit c369cd30bd
2 changed files with 13 additions and 2 deletions

View file

@ -312,17 +312,22 @@ const {
// 5. СЧЁТЧИК ПРОСМОТРОВ
const viewsEl = document.querySelector('.meta-views') as HTMLElement & { dataset: { postId: string } };
console.log('[Views] Element found:', viewsEl, 'postId:', viewsEl?.dataset?.postId);
if (viewsEl?.dataset?.postId) {
const postId = viewsEl.dataset.postId;
console.log('[Views] Fetching for post:', postId);
fetch(`/api/increment-views?postId=${postId}`)
.then(res => res.json())
.then(data => {
console.log('[Views] Response:', data);
if (data.views !== undefined) {
viewsEl.textContent = formatViews(data.views);
}
})
.catch(() => {});
.catch(err => {
console.error('[Views] Error:', err);
});
}
function formatViews(n: number): string {