Skip to content

Commit f1e34c2

Browse files
committed
Kategori bugu fixi.
1 parent 5f1a78c commit f1e34c2

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/pages/anlik-haber/index.astro

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ const SIDE_SLOT_COUNT = 3;
352352
}
353353

354354
function initNewsCategoryFilters() {
355+
const homeRoot = document.querySelector('[data-news-home-root]');
356+
if (!(homeRoot instanceof HTMLElement)) return;
355357
if (document.body.dataset.newsCategoryBound === '1') return;
356358
document.body.dataset.newsCategoryBound = '1';
357359

@@ -361,6 +363,8 @@ const SIDE_SLOT_COUNT = 3;
361363
document.querySelectorAll('[data-news-nav] a').forEach((link) => {
362364
if (!(link instanceof HTMLAnchorElement)) return;
363365
link.addEventListener('click', (event) => {
366+
const currentPath = window.location.pathname.replace(/\/+$/, '') || '/';
367+
if (currentPath !== '/anlik-haber') return;
364368
const url = new URL(link.href, window.location.origin);
365369
if (url.pathname !== '/anlik-haber/') return;
366370
event.preventDefault();
@@ -369,6 +373,7 @@ const SIDE_SLOT_COUNT = 3;
369373
});
370374

371375
window.addEventListener('popstate', () => {
376+
if (!document.querySelector('[data-news-home-root]')) return;
372377
applyCategory(categoryFromUrl(new URL(window.location.href)), false);
373378
});
374379
}

0 commit comments

Comments
 (0)