From 4cadb68dfe9b43672b8a2358a0ccfa67baba0621 Mon Sep 17 00:00:00 2001 From: Michael McQuade Date: Wed, 3 Feb 2021 09:21:11 -0600 Subject: [PATCH 1/2] Return a number from sort compare function (#21763) Changed the return values of the compare function from string values to numbers --- examples/blog-starter/lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/blog-starter/lib/api.js b/examples/blog-starter/lib/api.js index f684833c7c130..08da07eb78ab8 100644 --- a/examples/blog-starter/lib/api.js +++ b/examples/blog-starter/lib/api.js @@ -38,6 +38,6 @@ export function getAllPosts(fields = []) { const posts = slugs .map((slug) => getPostBySlug(slug, fields)) // sort posts by date in descending order - .sort((post1, post2) => (post1.date > post2.date ? '-1' : '1')) + .sort((post1, post2) => (post1.date > post2.date ? -1 : 1)) return posts } From e750f4378c25872b704197ee9161bee7eebb415c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Wed, 3 Feb 2021 16:28:25 +0100 Subject: [PATCH 2/2] fix: send url to gtm.pageview (#21747) `gtm.pageview` was called without sending an actual URL, while it is required here: https://github.com/vercel/next.js/blob/36aeca8f041a81ae01cae3c55e5c187a038e4166/examples/with-google-tag-manager/lib/gtm.js#L3-L6 --- .../components/GoogleTagManager.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/examples/with-google-tag-manager/components/GoogleTagManager.js b/examples/with-google-tag-manager/components/GoogleTagManager.js index 49b89be14c5f2..2be552492624d 100644 --- a/examples/with-google-tag-manager/components/GoogleTagManager.js +++ b/examples/with-google-tag-manager/components/GoogleTagManager.js @@ -2,17 +2,13 @@ import { useEffect } from 'react' import { useRouter } from 'next/router' import * as gtm from '../lib/gtm' -const handleRouteChange = () => { - gtm.pageview() -} - const GoogleTagManager = ({ children }) => { const router = useRouter() useEffect(() => { - router.events.on('routeChangeComplete', handleRouteChange) + router.events.on('routeChangeComplete', gtm.pageview) return () => { - router.events.off('routeChangeComplete', handleRouteChange) + router.events.off('routeChangeComplete', gtm.pageview) } }, [router.events])