From 24c94cbbd587275bcf7ddc590b5182b7f2b89d06 Mon Sep 17 00:00:00 2001 From: Abir Date: Sat, 12 Sep 2020 12:48:17 +0530 Subject: [PATCH 1/5] =?UTF-8?q?Added=20onRouteUpdate=20in=20versioned=5Fdo?= =?UTF-8?q?cs=20=F0=9F=91=A8=E2=80=8D=F0=9F=92=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added to version-2.0.0-alpha.63 --- .../version-2.0.0-alpha.63/docusaurus-core.md | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/website/versioned_docs/version-2.0.0-alpha.63/docusaurus-core.md b/website/versioned_docs/version-2.0.0-alpha.63/docusaurus-core.md index d5c78ea5809b..9b1f4be52a8e 100644 --- a/website/versioned_docs/version-2.0.0-alpha.63/docusaurus-core.md +++ b/website/versioned_docs/version-2.0.0-alpha.63/docusaurus-core.md @@ -298,6 +298,27 @@ const MyComponent = () => { }; ``` +### `onRouteUpdate({location})` + +Set the page field to current location on the default tracker, such that subsequent hits on this page are attributed to this page. +Recommended for Single-page Applications. + +Usage example: + +```jsx {2,5,6,7} +import React from 'react'; +import {onRouteUpdate} from '@docusaurus/useGlobalData'; + +const MyComponent = () => { + const location={ + pathname:'./example.html' + }; + + onRouteUpdate({location}); + return
Page value set to {location.pathname}
; +}; +``` + ## Modules ### `ExecutionEnvironment` From 55bc1ca017ece8fcb68c009653b674c818e194d8 Mon Sep 17 00:00:00 2001 From: Abir Date: Tue, 15 Sep 2020 18:03:02 +0530 Subject: [PATCH 2/5] Resolved Indentation Error. --- .../versioned_docs/version-2.0.0-alpha.63/docusaurus-core.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/website/versioned_docs/version-2.0.0-alpha.63/docusaurus-core.md b/website/versioned_docs/version-2.0.0-alpha.63/docusaurus-core.md index 9b1f4be52a8e..c63d8414c91f 100644 --- a/website/versioned_docs/version-2.0.0-alpha.63/docusaurus-core.md +++ b/website/versioned_docs/version-2.0.0-alpha.63/docusaurus-core.md @@ -310,9 +310,7 @@ import React from 'react'; import {onRouteUpdate} from '@docusaurus/useGlobalData'; const MyComponent = () => { - const location={ - pathname:'./example.html' - }; + const location = { pathname:'./example.html' }; onRouteUpdate({location}); return
Page value set to {location.pathname}
; From f4f486e2288b42f070bdaa38a4b351756e5007ad Mon Sep 17 00:00:00 2001 From: Abir Date: Wed, 16 Sep 2020 12:48:12 +0530 Subject: [PATCH 3/5] Removed the changes from versioned_docs --- .../version-2.0.0-alpha.63/docusaurus-core.md | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/website/versioned_docs/version-2.0.0-alpha.63/docusaurus-core.md b/website/versioned_docs/version-2.0.0-alpha.63/docusaurus-core.md index c63d8414c91f..d5c78ea5809b 100644 --- a/website/versioned_docs/version-2.0.0-alpha.63/docusaurus-core.md +++ b/website/versioned_docs/version-2.0.0-alpha.63/docusaurus-core.md @@ -298,25 +298,6 @@ const MyComponent = () => { }; ``` -### `onRouteUpdate({location})` - -Set the page field to current location on the default tracker, such that subsequent hits on this page are attributed to this page. -Recommended for Single-page Applications. - -Usage example: - -```jsx {2,5,6,7} -import React from 'react'; -import {onRouteUpdate} from '@docusaurus/useGlobalData'; - -const MyComponent = () => { - const location = { pathname:'./example.html' }; - - onRouteUpdate({location}); - return
Page value set to {location.pathname}
; -}; -``` - ## Modules ### `ExecutionEnvironment` From 1452afcb2606ffc34c9139290979e38d5e22ba3b Mon Sep 17 00:00:00 2001 From: Abir Date: Wed, 16 Sep 2020 12:49:25 +0530 Subject: [PATCH 4/5] Added the changes to master docs --- website/docs/docusaurus-core.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/website/docs/docusaurus-core.md b/website/docs/docusaurus-core.md index d5c78ea5809b..c63d8414c91f 100644 --- a/website/docs/docusaurus-core.md +++ b/website/docs/docusaurus-core.md @@ -298,6 +298,25 @@ const MyComponent = () => { }; ``` +### `onRouteUpdate({location})` + +Set the page field to current location on the default tracker, such that subsequent hits on this page are attributed to this page. +Recommended for Single-page Applications. + +Usage example: + +```jsx {2,5,6,7} +import React from 'react'; +import {onRouteUpdate} from '@docusaurus/useGlobalData'; + +const MyComponent = () => { + const location = { pathname:'./example.html' }; + + onRouteUpdate({location}); + return
Page value set to {location.pathname}
; +}; +``` + ## Modules ### `ExecutionEnvironment` From a41209d3ac94003fe234bbe8b10da2e4f29affc7 Mon Sep 17 00:00:00 2001 From: Abir Date: Wed, 16 Sep 2020 17:09:03 +0530 Subject: [PATCH 5/5] Updated onRouteUpdate Description --- website/docs/docusaurus-core.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/docs/docusaurus-core.md b/website/docs/docusaurus-core.md index c63d8414c91f..30751f4ef2ba 100644 --- a/website/docs/docusaurus-core.md +++ b/website/docs/docusaurus-core.md @@ -300,7 +300,8 @@ const MyComponent = () => { ### `onRouteUpdate({location})` -Set the page field to current location on the default tracker, such that subsequent hits on this page are attributed to this page. +If the current rendering environment is on client i.e. `ExecutionEnvironment.canUseDOM === true`, then `onRouteUpdate({location})` updates the Google Analytics plugin +by setting the page value to current path, inorder to measure the number of views one had for a particular page on the website. Recommended for Single-page Applications. Usage example: