From eb510dfe3e32673eab2ba7756dbb197f1539455c Mon Sep 17 00:00:00 2001 From: tison Date: Wed, 2 Nov 2022 09:40:45 +0800 Subject: [PATCH] fix: use document.title after page load This is the same solution as https://github.com/facebook/docusaurus/pull/7424. Signed-off-by: tison --- globalClientModule.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/globalClientModule.ts b/globalClientModule.ts index 1452a09..fd84041 100644 --- a/globalClientModule.ts +++ b/globalClientModule.ts @@ -5,11 +5,11 @@ const module: ClientModule = { onRouteDidUpdate({location, previousLocation}) { if (ExecutionEnvironment.canUseDOM) { if (location.pathname != previousLocation?.pathname) { - _paq.push(['setCustomUrl', location.pathname]) - _paq.push(['setDocumentTitle', document.title]) - _paq.push(['trackPageView']) - console.log(`path = ${location.pathname}`) - console.log(`title = ${document.title}`) + setTimeout(() => { + _paq.push(['setCustomUrl', location.pathname]) + _paq.push(['setDocumentTitle', document.title]) + _paq.push(['trackPageView']) + }) } } }