fix skipping first navigation

This commit is contained in:
Daniel Bulant 2023-10-14 22:05:43 +02:00
parent f5d7d2108b
commit dce011fcd3

View file

@ -10,12 +10,10 @@
if(browser) { if(browser) {
apm.setInitialPageLoadName($page.route.id); apm.setInitialPageLoadName($page.route.id);
} }
let skipFirst = true;
let last = typeof window !== "undefined" && window.location.pathname; let last = typeof window !== "undefined" && window.location.pathname;
afterNavigate(page => { afterNavigate(page => {
if(!["link", "popstate"].includes(page.type)) return; // ignore post hydration and automatic goto if(!["link", "popstate"].includes(page.type)) return; // ignore post hydration and automatic goto
if(skipFirst) return skipFirst = false;
if(window.goatcounter) window.goatcounter.count({ if(window.goatcounter) window.goatcounter.count({
path: window.location.pathname, path: window.location.pathname,
title: page.title, title: page.title,