diff options
| author | Yuval Adam <_@yuv.al> | 2025-06-15 13:44:39 +0200 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2025-06-15 13:44:39 +0200 |
| commit | dd100d4c821aae71f4a43b10843c74f14480bbc0 (patch) | |
| tree | 6739853a863b26d0a5896796efeb43e27b219586 /src/components | |
| parent | 2e0755cc68e14bda95abe9472754ae5f4e760a04 (diff) | |
| parent | abee8fa7e82e66765ca8b513f9dc1a7bac814779 (diff) | |
Merge remote-tracking branch 'v2/main'
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/Analytics.astro | 33 | ||||
| -rw-r--r-- | src/components/Counter.jsx | 16 | ||||
| -rw-r--r-- | src/components/NameLink.astro | 42 |
3 files changed, 91 insertions, 0 deletions
diff --git a/src/components/Analytics.astro b/src/components/Analytics.astro new file mode 100644 index 0000000..0352bea --- /dev/null +++ b/src/components/Analytics.astro @@ -0,0 +1,33 @@ +--- +import { analytics } from "../config/analytics"; + +const GOOGLE_ANALYTICS_ID = analytics.googleAnalyticsId; +const FATHOM_ANALYTICS_ID = analytics.fathomAnalyticsId; +--- + +{ + GOOGLE_ANALYTICS_ID && ( + <script + async + src={`https://www.googletagmanager.com/gtag/js?id=${GOOGLE_ANALYTICS_ID}`} + /> + <script define:vars={{ GOOGLE_ANALYTICS_ID }} is:inline> + window.dataLayer = window.dataLayer || []; + function gtag() { + dataLayer.push(arguments); + } + gtag("js", new Date()); + gtag("config", GOOGLE_ANALYTICS_ID); + </script> + ) +} +{ + FATHOM_ANALYTICS_ID && ( + <script + src="https://cdn.usefathom.com/script.js" + data-site={FATHOM_ANALYTICS_ID} + defer + /> + ) +} + diff --git a/src/components/Counter.jsx b/src/components/Counter.jsx new file mode 100644 index 0000000..8661dc0 --- /dev/null +++ b/src/components/Counter.jsx @@ -0,0 +1,16 @@ +import { useState } from 'react'; + +export default function Counter() { + const [count, setCount] = useState(0); + + return ( + <div className="flex justify-center"> + <button + className="px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600 transition-colors" + onClick={() => setCount(count + 1)} + > + Clicked {count} times + </button> + </div> + ); +} diff --git a/src/components/NameLink.astro b/src/components/NameLink.astro new file mode 100644 index 0000000..8ceb7e1 --- /dev/null +++ b/src/components/NameLink.astro @@ -0,0 +1,42 @@ +--- +interface Props { + name: { + data: { + name: string; + domain: string; + url?: string; + candidate?: boolean; + }; + }; + size?: 'large' | 'small'; +} + +const { name, size = 'large' } = Astro.props; +const nameParts = name.data.name.toLowerCase().split(" "); +const domain = name.data.domain.replace(".", ""); +const url = name.data.url || `https://${name.data.domain}`; + +const sizeClasses = { + large: 'text-2xl', + small: 'text-xl' +}; +--- + +<span class={sizeClasses[size]}> + {nameParts.map((part, index) => ( + <> + {index > 0 && " "} + {part === domain ? ( + <a + href={url} + class="text-blue-600 hover:text-blue-800 hover:underline" + rel={name.data.candidate ? "nofollow" : undefined} + > + {name.data.domain} + </a> + ) : ( + <span>{part}</span> + )} + </> + ))} +</span>
\ No newline at end of file |
