Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/danielroe/roe.dev. This is the code and content for my personal website, built in Nuxt. roe.dev
Something went wrong. Try again.
TypeScript
at feat/nuxt-v5
123456789101112131415161718192021222324252627282930313233343536373839404142434445import { defineEventHandler, getRequestHeader, sendRedirect } from 'nuxt/server'
const BOT_RE = /bot\b|index|spider|facebookexternalhit|crawl|wget|slurp|mediapartners-google|whatsapp|twitter|linkedin|mastodon|bluesky|bsky/i
export default defineEventHandler(async event => { event.res.headers.set('vary', 'user-agent')
const userAgent = getRequestHeader(event, 'user-agent') const isOpenGraphCrawler = userAgent && BOT_RE.test(userAgent) if (!isOpenGraphCrawler) { return sendRedirect(event, 'https://twitch.tv/danielroe') }
event.res.headers.set('content-type', 'text/html')
return `<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="refresh" content="0; url=https://twitch.tv/danielroe"> <title>Daniel Roe live stream</title> <meta name="description" content="Join me live on Twitch."> <!-- Open Graph / Facebook --> <meta property="og:type" content="website"> <meta property="og:url" content="https://roe.dev/stream"> <meta property="og:title" content="Daniel Roe live stream"> <meta property="og:description" content="Join me live on Twitch."> <meta property="og:image" content="https://roe.dev/stream.jpg"> <meta property="og:image:alt" content="Daniel Roe Live Stream"> <!-- Twitter --> <meta name="twitter:card" content="summary_large_image"> <meta name="twitter:url" content="https://roe.dev/stream"> <meta name="twitter:title" content="Daniel Roe live stream"> <meta name="twitter:description" content="Join me live on Twitch."> <meta name="twitter:image" content="https://roe.dev/stream.jpg"></head><body> <script>window.location.href = 'https://twitch.tv/danielroe'</script></body></html>`})