Skip to content

Commit 91260a9

Browse files
committed
fix(with-facebook-pixel): prettier
1 parent e62c64a commit 91260a9

File tree

6 files changed

+47
-49
lines changed

6 files changed

+47
-49
lines changed
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import Link from "next/link";
1+
import Link from 'next/link'
22

33
export default function About() {
44
return (
55
<>
66
<h1>About</h1>
77

8-
<Link href="/">
9-
back to home
10-
</Link>
8+
<Link href="/">back to home</Link>
119
</>
12-
);
10+
)
1311
}
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
'use client';
1+
'use client'
22

3-
import { usePathname } from 'next/navigation';
4-
import Script from 'next/script';
5-
import { useEffect, useState } from 'react';
6-
import * as pixel from '/lib/fpixel';
3+
import { usePathname } from 'next/navigation'
4+
import Script from 'next/script'
5+
import { useEffect, useState } from 'react'
6+
import * as pixel from '/lib/fpixel'
77

88
const FacebookPixel = () => {
9-
const [loaded, setLoaded] = useState(false);
10-
const pathname = usePathname();
9+
const [loaded, setLoaded] = useState(false)
10+
const pathname = usePathname()
1111

1212
useEffect(() => {
13-
if (!loaded) return;
13+
if (!loaded) return
1414

15-
pixel.pageview();
16-
}, [pathname, loaded]);
15+
pixel.pageview()
16+
}, [pathname, loaded])
1717

1818
return (
1919
<div>
@@ -25,7 +25,7 @@ const FacebookPixel = () => {
2525
data-pixel-id={pixel.FB_PIXEL_ID}
2626
/>
2727
</div>
28-
);
29-
};
28+
)
29+
}
3030

31-
export default FacebookPixel;
31+
export default FacebookPixel
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { default as FacebookPixel } from './FacebookPixel';
1+
export { default as FacebookPixel } from './FacebookPixel'
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import { FacebookPixel } from './components';
1+
import { FacebookPixel } from './components'
22

3-
export default function RootLayout({
4-
children,
5-
}) {
3+
export default function RootLayout({ children }) {
64
return (
75
<html lang="en">
86
<body>
97
{children}
108
<FacebookPixel />
119
</body>
1210
</html>
13-
);
11+
)
1412
}
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
import Link from "next/link";
1+
import Link from 'next/link'
22

33
export default function Home() {
44
return (
55
<>
66
<h2>
7-
Go to `app/layout.js` to see how implement Facebook Pixel in NextJS ˆ13 with app folder
7+
Go to `app/layout.js` to see how implement Facebook Pixel in NextJS ˆ13
8+
with app folder
89
</h2>
9-
<h2>
10-
If you want to see old implementation, go to `_pages/index.js`
11-
</h2>
12-
<Link href="/about">
13-
About page
14-
</Link>
10+
<h2>If you want to see old implementation, go to `_pages/index.js`</h2>
11+
<Link href="/about">About page</Link>
1512
</>
16-
);
13+
)
1714
}
Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
const PIXEL_ID = document.currentScript.getAttribute('data-pixel-id')
22

33
function initializeFacebookPixel(f, b, e, v, n, t, s) {
4-
if(f.fbq) return;
5-
n = f.fbq = function() {
6-
n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);
7-
};
8-
if(!f._fbq) f._fbq = n;
9-
n.push = n;
10-
n.loaded = !0;
11-
n.version = '2.0';
12-
n.queue = [];
13-
t = b.createElement(e);
14-
t.async = !0;
15-
t.src = v;
16-
s = b.getElementsByTagName(e)[0];
17-
s.parentNode.insertBefore(t, s);
4+
if (f.fbq) return
5+
n = f.fbq = function () {
6+
n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments)
7+
}
8+
if (!f._fbq) f._fbq = n
9+
n.push = n
10+
n.loaded = !0
11+
n.version = '2.0'
12+
n.queue = []
13+
t = b.createElement(e)
14+
t.async = !0
15+
t.src = v
16+
s = b.getElementsByTagName(e)[0]
17+
s.parentNode.insertBefore(t, s)
1818
}
1919

20-
initializeFacebookPixel(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');
20+
initializeFacebookPixel(
21+
window,
22+
document,
23+
'script',
24+
'https://connect.facebook.net/en_US/fbevents.js'
25+
)
2126

22-
window.fbq('init', PIXEL_ID);
27+
window.fbq('init', PIXEL_ID)

0 commit comments

Comments
 (0)