/** * Cloudflare Worker for Dynamic Open Graph Tags * * Deploy this as a Cloudflare Worker to handle /share routes * and inject dynamic OG tags based on URL parameters. * * URL format: https://portfoliojournal.app/share?goal=My%20Goal&progress=42 * * Setup: * 1. Go to Cloudflare Dashboard > Workers * 2. Create a new Worker * 3. Paste this code * 4. Add a route: portfoliojournal.app/share* */ export default { async fetch(request) { const url = new URL(request.url); // Only handle /share routes if (!url.pathname.startsWith('/share')) { return fetch(request); } // Get parameters const goalName = url.searchParams.get('goal') || 'Investment Goal'; const progress = parseInt(url.searchParams.get('progress')) || 0; // Build dynamic OG content const ogTitle = `I'm ${progress}% towards my "${goalName}" goal! 🎯`; const ogDescription = 'Track your investment goals with Portfolio Journal. Download free on the App Store.'; const ogImage = 'https://portfoliojournal.app/images/og-share-card.png'; const appStoreUrl = 'https://apps.apple.com/app/portfolio-journal/id6744983373'; const html = `
Track your investment goals and celebrate your financial milestones.
Download Free