fix: connect command palette to analytics modal and update github link
All checks were successful
Deploy Portfolio to VPS / deploy (push) Successful in 21s
All checks were successful
Deploy Portfolio to VPS / deploy (push) Successful in 21s
This commit is contained in:
parent
d4f76bb1ff
commit
7b6f2299bb
2 changed files with 15 additions and 7 deletions
|
|
@ -24,18 +24,26 @@ export default function AnalyticsWidget() {
|
||||||
.catch((err) => console.error("Analytics Widget Fetch Error:", err));
|
.catch((err) => console.error("Analytics Widget Fetch Error:", err));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Initial load on client hydration: track page view
|
|
||||||
useEffect(() => {
|
|
||||||
setMounted(true);
|
|
||||||
fetchStats(true); // track=true on initial page visit
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// Open modal and silently refresh stats without incrementing view count
|
// Open modal and silently refresh stats without incrementing view count
|
||||||
const handleOpenModal = () => {
|
const handleOpenModal = () => {
|
||||||
fetchStats(false); // track=false when clicking badge
|
fetchStats(false); // track=false when clicking badge
|
||||||
setIsOpen(true);
|
setIsOpen(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Hydrate client, fetch initial page metrics, and listen for custom Cmd+K palette events
|
||||||
|
useEffect(() => {
|
||||||
|
setMounted(true);
|
||||||
|
fetchStats(true); // Track initial page view
|
||||||
|
|
||||||
|
// Listen for custom trigger event fired from CommandPalette
|
||||||
|
const handleCustomOpen = () => handleOpenModal();
|
||||||
|
window.addEventListener("open-analytics", handleCustomOpen);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("open-analytics", handleCustomOpen);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
// Skeleton badge while client hydration occurs or metrics are loading
|
// Skeleton badge while client hydration occurs or metrics are loading
|
||||||
if (!mounted || !stats) {
|
if (!mounted || !stats) {
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ export const getCommands = (
|
||||||
icon: "🐙",
|
icon: "🐙",
|
||||||
action: () => {
|
action: () => {
|
||||||
window.open(
|
window.open(
|
||||||
"https://github.com/andre-kempf",
|
"https://github.com/Chneemann",
|
||||||
"_blank",
|
"_blank",
|
||||||
"noopener,noreferrer",
|
"noopener,noreferrer",
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue