Skip to content

Commit 4b8cc52

Browse files
committed
add meta pixel
1 parent 1cb67a9 commit 4b8cc52

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;600;700&display=swap" />
2424
</head>
2525
<body>
26+
<script></script>
2627
<div id="root"></div>
2728
<script type="module" src="/src/%VITE_HOST%.tsx"></script>
2829
</body>

vite.config.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ const htmlPlugin = () => {
1717
).replace(
1818
/<meta name="description" content="(.*?)" \/>/,
1919
`<meta name="description" content="${description()}" />`
20+
).replace(
21+
/<script><\/script>/,
22+
scripts()
2023
)
2124
},
2225
}
@@ -53,3 +56,29 @@ function description() {
5356
return 'OPEN SOURCE IS A TREASURE TROVE. What jewel will you discover today?'
5457
}
5558
}
59+
60+
function scripts() {
61+
switch (process.env.VITE_HOST) {
62+
case 'pkgx.dev':
63+
return `<script>
64+
!function (f, b, e, v, n, t, s) {
65+
if (f.fbq) return; n = f.fbq = function () {
66+
n.callMethod ?
67+
n.callMethod.apply(n, arguments) : n.queue.push(arguments)
68+
};
69+
if (!f._fbq) f._fbq = n; n.push = n; n.loaded = !0; n.version = '2.0';
70+
n.queue = []; t = b.createElement(e); t.async = !0;
71+
t.src = v; s = b.getElementsByTagName(e)[0];
72+
s.parentNode.insertBefore(t, s)
73+
}(window, document, 'script',
74+
'https://connect.facebook.net/en_US/fbevents.js');
75+
fbq('init', '1632217704843931');
76+
fbq('track', 'PageView');
77+
</script>
78+
<noscript>
79+
<img height="1" width="1" style="display:none"
80+
src="https://www.facebook.com/tr?id=1632217704843931&ev=PageView&noscript=1" />
81+
</noscript>`;
82+
default: return '';
83+
}
84+
}

0 commit comments

Comments
 (0)