|
55 | 55 | }); |
56 | 56 |
|
57 | 57 | const origin = $derived(page.url.origin); |
| 58 | + const dataParam = $derived(page.url.searchParams.get('data')); |
58 | 59 | const ogImage = $derived.by(() => { |
59 | | - const p = page.url.searchParams.get('data'); |
60 | | - if (p) return `${origin}/api/og?data=${encodeURIComponent(p)}`; |
| 60 | + if (dataParam) return `${origin}/api/og?data=${encodeURIComponent(dataParam)}`; |
61 | 61 | return `${origin}/api/og`; |
62 | 62 | }); |
63 | | - const canonical = $derived(page.url.origin + page.url.pathname); |
| 63 | + // Canonical / og:url must include the `?data=...` payload when present. |
| 64 | + // Without it, Facebook resolves each shared URL back to the bare landing page, reuses its |
| 65 | + // cached og:image (the generic preview), and never shows the visualization for the actual |
| 66 | + // share. Each `?data=...` URL is a distinct shareable view and deserves its own canonical. |
| 67 | + const canonical = $derived.by(() => { |
| 68 | + const base = page.url.origin + page.url.pathname; |
| 69 | + return dataParam ? `${base}?data=${encodeURIComponent(dataParam)}` : base; |
| 70 | + }); |
64 | 71 |
|
65 | 72 | const authorSite = 'https://danipolani.github.io/en/'; |
66 | 73 | const toolsPage = 'https://danipolani.github.io/en/blog/tools/'; |
|
77 | 84 | <meta property="og:description" content={DEFAULT_DESCRIPTION} /> |
78 | 85 | <meta property="og:url" content={canonical} /> |
79 | 86 | <meta property="og:image" content={ogImage} /> |
| 87 | + <meta property="og:image:secure_url" content={ogImage} /> |
80 | 88 | <meta property="og:image:type" content="image/png" /> |
81 | 89 | <meta property="og:image:width" content="1200" /> |
82 | 90 | <meta property="og:image:height" content="630" /> |
|
0 commit comments