2Btainment commited on
Commit
5120828
·
1 Parent(s): af90375

fix: load Buy Me a Coffee after React mount

Browse files

Sync BMC script in index.html body could clear #root before
the SPA mounts, leaving only the floating coffee button.
Restore Vite shell and inject BMC from App useEffect instead.

Files changed (2) hide show
  1. frontend/index.html +1 -2
  2. frontend/src/App.tsx +16 -1
frontend/index.html CHANGED
@@ -9,6 +9,5 @@
9
  <body>
10
  <div id="root"></div>
11
  <script type="module" src="/src/main.tsx"></script>
12
- <script type="text/javascript" src="https://cdnjs.buymeacoffee.com/1.0.0/button.prod.min.js" data-name="bmc-button" data-slug="2btainment" data-color="#FFDD00" data-emoji="" data-font="Cookie" data-text="Buy me a coffee" data-outline-color="#000000" data-font-color="#000000" data-coffee-color="#ffffff"></script>
13
- </body>
14
  </html>
 
9
  <body>
10
  <div id="root"></div>
11
  <script type="module" src="/src/main.tsx"></script>
12
+ </body>
 
13
  </html>
frontend/src/App.tsx CHANGED
@@ -73,7 +73,22 @@ export default function App() {
73
  }, [analysis, selected, url, token]);
74
 
75
  useEffect(() => {
76
- // no-op placeholder for future locale switch
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  }, []);
78
 
79
  const space = analysis?.space;
 
73
  }, [analysis, selected, url, token]);
74
 
75
  useEffect(() => {
76
+ // Load BMC after React mounts so button.prod.min.js cannot clear #root
77
+ if (document.querySelector('script[data-name="bmc-button"]')) return;
78
+ const s = document.createElement("script");
79
+ s.type = "text/javascript";
80
+ s.src = "https://cdnjs.buymeacoffee.com/1.0.0/button.prod.min.js";
81
+ s.setAttribute("data-name", "bmc-button");
82
+ s.setAttribute("data-slug", "2btainment");
83
+ s.setAttribute("data-color", "#FFDD00");
84
+ s.setAttribute("data-emoji", "");
85
+ s.setAttribute("data-font", "Cookie");
86
+ s.setAttribute("data-text", "Buy me a coffee");
87
+ s.setAttribute("data-outline-color", "#000000");
88
+ s.setAttribute("data-font-color", "#000000");
89
+ s.setAttribute("data-coffee-color", "#ffffff");
90
+ s.async = true;
91
+ document.body.appendChild(s);
92
  }, []);
93
 
94
  const space = analysis?.space;