Skip to content

Commit

Permalink
Draft Deploy to check if script run on desktop only
Browse files Browse the repository at this point in the history
  • Loading branch information
Kawtar Choubari committed Sep 25, 2023
1 parent 1ec4523 commit d2a4b4a
Show file tree
Hide file tree
Showing 3 changed files with 3,176 additions and 3,022 deletions.
34 changes: 21 additions & 13 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Providers } from "@/lib/provider";
import Footer from "@/components/footer";
import { siteConfig } from "@/config/site";
import Analytics from "@/components/analytics";
import { isDesktop, isMobile } from "react-device-detect";

export const metadata = {
title: siteConfig.name,
Expand Down Expand Up @@ -62,6 +63,8 @@ export default function RootLayout({
}: {
children: React.ReactNode;
}) {
console.log("isMobile ", isMobile);
console.log("isDesktop ", isDesktop);
return (
<html lang="en" suppressHydrationWarning={true}>
<body
Expand All @@ -78,19 +81,24 @@ export default function RootLayout({
<Footer />
{/* TODO: replace with html script tag as the Nextjs Script didn't work */}
{/* TODO: load this script only on desktop */}
{/* <Script
data-name="BMC-Widget"
data-cfasync="false"
src="https://cdnjs.buymeacoffee.com/1.0.0/widget.prod.min.js"
data-id="choubari"
data-description="Support me on Buy me a coffee!"
data-message="Thank you for visiting my website! You may want to buy me a coffee ;)"
data-color="#12c5ca"
data-position="Right"
data-x_margin="18"
data-y_margin="18"
strategy="lazyOnload"
></Script> */}
<h1 className="text-xl font-bold">
isDesktop{":" + isDesktop}, isMobile{":" + isMobile}
</h1>
{isDesktop && (
<script
data-name="BMC-Widget"
data-cfasync="false"
src="https://cdnjs.buymeacoffee.com/1.0.0/widget.prod.min.js"
data-id="choubari"
data-description="Support me on Buy me a coffee!"
data-message="Thank you for visiting my website! You may want to buy me a coffee ;)"
data-color="#12c5ca"
data-position="Right"
data-x_margin="18"
data-y_margin="18"
// strategy="lazyOnload"
></script>
)}
</body>
</html>
);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"next-themes": "^0.2.1",
"postcss": "8.4.23",
"react": "18.2.0",
"react-device-detect": "^2.2.3",
"react-dom": "18.2.0",
"react-google-recaptcha": "^3.1.0",
"react-icons": "^4.8.0",
Expand Down
Loading

0 comments on commit d2a4b4a

Please sign in to comment.