refactor: migrate TrumpSignal to TypeScript monorepo and Pages Router
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Apple touch icon (180×180) — also used as the PWA icon source.
|
||||
*
|
||||
* iOS Safari grabs <link rel="apple-touch-icon"> when "Add to Home Screen"
|
||||
* is invoked. Next.js auto-wires this file to that link.
|
||||
*/
|
||||
import { ImageResponse } from 'next/og'
|
||||
|
||||
const size = { width: 180, height: 180 }
|
||||
const contentType = 'image/png'
|
||||
|
||||
function AppleIcon() {
|
||||
return new ImageResponse(
|
||||
<div
|
||||
style={{
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
background: '#0a0907',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
fontSize: 132,
|
||||
fontWeight: 700,
|
||||
color: '#f5a524',
|
||||
fontFamily: 'system-ui, sans-serif',
|
||||
lineHeight: 1,
|
||||
borderRadius: 24,
|
||||
}}
|
||||
>
|
||||
α
|
||||
</div>,
|
||||
{ ...size },
|
||||
)
|
||||
}
|
||||
|
||||
export default async function handler(
|
||||
_req: import('next').NextApiRequest,
|
||||
res: import('next').NextApiResponse,
|
||||
) {
|
||||
const image = AppleIcon()
|
||||
res.setHeader('Content-Type', 'image/png')
|
||||
res.setHeader('Cache-Control', 'public, max-age=86400')
|
||||
res.send(Buffer.from(await image.arrayBuffer()))
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Dynamic favicon. Renders the brand mark (α) on the dark brand background.
|
||||
*
|
||||
* Next.js auto-discovers this file and wires it into the page <head> as
|
||||
* <link rel="icon"> for every route. No static asset needed in /public.
|
||||
*
|
||||
* For larger PWA install icons (192/512), see app/apple-icon.tsx and the
|
||||
* manifest.ts entries that reference them.
|
||||
*/
|
||||
import { ImageResponse } from 'next/og'
|
||||
|
||||
const size = { width: 64, height: 64 }
|
||||
const contentType = 'image/png'
|
||||
|
||||
function Icon() {
|
||||
return new ImageResponse(
|
||||
<div
|
||||
style={{
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
background: '#0a0907',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
fontSize: 44,
|
||||
fontWeight: 700,
|
||||
color: '#f5a524',
|
||||
fontFamily: 'system-ui, sans-serif',
|
||||
lineHeight: 1,
|
||||
}}
|
||||
>
|
||||
α
|
||||
</div>,
|
||||
{ ...size },
|
||||
)
|
||||
}
|
||||
|
||||
export default async function handler(
|
||||
_req: import('next').NextApiRequest,
|
||||
res: import('next').NextApiResponse,
|
||||
) {
|
||||
const image = Icon()
|
||||
res.setHeader('Content-Type', 'image/png')
|
||||
res.setHeader('Cache-Control', 'public, max-age=86400')
|
||||
res.send(Buffer.from(await image.arrayBuffer()))
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import type { MetadataRoute } from 'next'
|
||||
|
||||
function manifest(): MetadataRoute.Manifest {
|
||||
return {
|
||||
name: 'Trump Alpha',
|
||||
short_name: 'Trump Alpha',
|
||||
description:
|
||||
'Four crypto alpha feeds, one dashboard. Trump signals, BTC on-chain, KOL analysis, talks-vs-trades.',
|
||||
start_url: '/en',
|
||||
display: 'standalone',
|
||||
background_color: '#0a0907',
|
||||
theme_color: '#f5a524',
|
||||
orientation: 'portrait-primary',
|
||||
categories: ['finance', 'utilities'],
|
||||
// Icons sourced from Next's dynamic generators (app/icon.tsx,
|
||||
// app/apple-icon.tsx) — no static PNG asset required. `sizes: 'any'` lets
|
||||
// the install prompt accept whatever resolution the OS asks for since
|
||||
// ImageResponse renders at any size we declare in those files.
|
||||
icons: [
|
||||
{
|
||||
src: '/icon',
|
||||
sizes: 'any',
|
||||
type: 'image/png',
|
||||
purpose: 'any',
|
||||
},
|
||||
{
|
||||
src: '/apple-icon',
|
||||
sizes: '180x180',
|
||||
type: 'image/png',
|
||||
purpose: 'maskable',
|
||||
},
|
||||
],
|
||||
screenshots: [
|
||||
{
|
||||
src: '/opengraph-image',
|
||||
sizes: '1200x630',
|
||||
type: 'image/png',
|
||||
form_factor: 'wide',
|
||||
label: 'Trump Alpha dashboard',
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
export default function handler(
|
||||
_req: import('next').NextApiRequest,
|
||||
res: import('next').NextApiResponse,
|
||||
) {
|
||||
res.setHeader('Content-Type', 'application/manifest+json')
|
||||
res.json(manifest())
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
import { ImageResponse } from 'next/og'
|
||||
|
||||
const alt = 'Trump Alpha — the crypto signals that move price before the crowd, by Endorphin'
|
||||
const size = { width: 1200, height: 630 }
|
||||
const contentType = 'image/png'
|
||||
|
||||
function OGImage() {
|
||||
return new ImageResponse(
|
||||
<div
|
||||
style={{
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'flex-start',
|
||||
justifyContent: 'flex-end',
|
||||
padding: '64px 72px',
|
||||
background: '#0a0907',
|
||||
position: 'relative',
|
||||
overflow: 'hidden',
|
||||
fontFamily: 'system-ui, sans-serif',
|
||||
}}
|
||||
>
|
||||
{/* Background grid */}
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
inset: 0,
|
||||
backgroundImage:
|
||||
'linear-gradient(rgba(245,165,36,0.04) 1px, transparent 1px), linear-gradient(90deg, rgba(245,165,36,0.04) 1px, transparent 1px)',
|
||||
backgroundSize: '48px 48px',
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Ambient glow */}
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: -200,
|
||||
left: -200,
|
||||
width: 800,
|
||||
height: 800,
|
||||
borderRadius: '50%',
|
||||
background: 'radial-gradient(circle, rgba(245,165,36,0.12) 0%, transparent 70%)',
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Top-right corner badge */}
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: 48,
|
||||
right: 72,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: 8,
|
||||
padding: '6px 14px',
|
||||
borderRadius: 999,
|
||||
background: 'rgba(245,165,36,0.12)',
|
||||
border: '1px solid rgba(245,165,36,0.3)',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
width: 8,
|
||||
height: 8,
|
||||
borderRadius: '50%',
|
||||
background: '#22c55e',
|
||||
}}
|
||||
/>
|
||||
<span style={{ fontSize: 14, color: '#f5a524', fontWeight: 700, letterSpacing: '0.06em' }}>
|
||||
LIVE
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Four signal pills */}
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
gap: 12,
|
||||
marginBottom: 40,
|
||||
flexWrap: 'wrap',
|
||||
}}
|
||||
>
|
||||
{[
|
||||
{ label: 'Trump · Truth Social', color: '#f5a524' },
|
||||
{ label: 'Macro Vibes', color: '#a78bfa' },
|
||||
{ label: 'KOL Signal', color: '#22c55e' },
|
||||
{ label: 'Talks vs Trades', color: '#ef4444' },
|
||||
].map((p) => (
|
||||
<div
|
||||
key={p.label}
|
||||
style={{
|
||||
display: 'flex',
|
||||
padding: '7px 16px',
|
||||
borderRadius: 6,
|
||||
background: 'rgba(255,255,255,0.05)',
|
||||
border: `1px solid ${p.color}40`,
|
||||
fontSize: 13,
|
||||
fontWeight: 600,
|
||||
color: p.color,
|
||||
letterSpacing: '0.02em',
|
||||
}}
|
||||
>
|
||||
{p.label}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Main title */}
|
||||
<div
|
||||
style={{
|
||||
fontSize: 72,
|
||||
fontWeight: 800,
|
||||
lineHeight: 1.05,
|
||||
color: '#f5f2ea',
|
||||
marginBottom: 24,
|
||||
letterSpacing: '-0.03em',
|
||||
}}
|
||||
>
|
||||
Trump Alpha
|
||||
</div>
|
||||
|
||||
{/* Sub */}
|
||||
<div
|
||||
style={{
|
||||
fontSize: 24,
|
||||
color: '#8a8578',
|
||||
fontWeight: 400,
|
||||
lineHeight: 1.5,
|
||||
maxWidth: 700,
|
||||
marginBottom: 0,
|
||||
}}
|
||||
>
|
||||
The crypto signals that move price before the crowd.
|
||||
<br />A research desk by Endorphin — public, live, timestamped.
|
||||
</div>
|
||||
|
||||
{/* Bottom right stat strip */}
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
bottom: 52,
|
||||
right: 72,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'flex-end',
|
||||
gap: 6,
|
||||
}}
|
||||
>
|
||||
{[
|
||||
{ v: '<3s', l: 'post → position' },
|
||||
{ v: '25', l: 'KOL feeds' },
|
||||
{ v: '$0', l: 'platform fee' },
|
||||
].map((s) => (
|
||||
<div key={s.l} style={{ display: 'flex', gap: 10, alignItems: 'baseline' }}>
|
||||
<span
|
||||
style={{ fontSize: 22, fontWeight: 700, color: '#f5a524', fontFamily: 'monospace' }}
|
||||
>
|
||||
{s.v}
|
||||
</span>
|
||||
<span style={{ fontSize: 13, color: '#5c584e' }}>{s.l}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>,
|
||||
{ ...size },
|
||||
)
|
||||
}
|
||||
|
||||
export default async function handler(
|
||||
_req: import('next').NextApiRequest,
|
||||
res: import('next').NextApiResponse,
|
||||
) {
|
||||
const image = OGImage()
|
||||
res.setHeader('Content-Type', 'image/png')
|
||||
res.setHeader('Cache-Control', 'public, max-age=86400')
|
||||
res.send(Buffer.from(await image.arrayBuffer()))
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
export const config = { api: { bodyParser: false, responseLimit: '8mb' } }
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const path = req.query.path
|
||||
if (!Array.isArray(path) || path.some((p) => p === '..' || p.includes('/') || p.includes('\\')))
|
||||
return res.status(400).json({ error: 'Invalid path' })
|
||||
const base = process.env.API_URL || process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000'
|
||||
const target = new URL('/' + path.map(encodeURIComponent).join('/'), base)
|
||||
const incoming = new URL(req.url ?? '/', 'http://localhost')
|
||||
target.search = incoming.search
|
||||
const headers = new Headers()
|
||||
const hop = new Set([
|
||||
'host',
|
||||
'connection',
|
||||
'transfer-encoding',
|
||||
'content-length',
|
||||
'keep-alive',
|
||||
'upgrade',
|
||||
'x-forwarded-host',
|
||||
'x-forwarded-proto',
|
||||
])
|
||||
for (const [k, v] of Object.entries(req.headers))
|
||||
if (v && !hop.has(k)) headers.set(k, Array.isArray(v) ? v.join(',') : v)
|
||||
headers.set('accept-encoding', 'identity')
|
||||
try {
|
||||
const chunks: Buffer[] = []
|
||||
let bytes = 0
|
||||
for await (const chunk of req) {
|
||||
const b = Buffer.from(chunk)
|
||||
bytes += b.length
|
||||
if (bytes > 1024 * 1024) return res.status(413).end()
|
||||
chunks.push(b)
|
||||
}
|
||||
const body = req.method === 'GET' || req.method === 'HEAD' ? undefined : Buffer.concat(chunks)
|
||||
const upstream = await fetch(target, {
|
||||
method: req.method,
|
||||
headers,
|
||||
body,
|
||||
signal: AbortSignal.timeout(30_000),
|
||||
redirect: 'manual',
|
||||
})
|
||||
upstream.headers.forEach((v, k) => {
|
||||
if (!hop.has(k) && k !== 'content-encoding') res.setHeader(k, v)
|
||||
})
|
||||
res.status(upstream.status).send(Buffer.from(await upstream.arrayBuffer()))
|
||||
} catch {
|
||||
res.status(502).json({ error: 'Upstream request failed' })
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import type { MetadataRoute } from 'next'
|
||||
|
||||
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://trumpsignal.com'
|
||||
|
||||
// Settings page is user-personalized (wallet address, HL keys, alert prefs).
|
||||
// Disallow under every locale prefix in case any /zh URLs survive in the wild
|
||||
// — i18n is shelved but the routes still resolve.
|
||||
const SETTINGS_DENY = ['/api/', '/_next/', '/en/settings', '/zh/settings']
|
||||
|
||||
function robots(): MetadataRoute.Robots {
|
||||
return {
|
||||
rules: [
|
||||
// Default: allow everything except private pages
|
||||
{
|
||||
userAgent: '*',
|
||||
allow: '/',
|
||||
disallow: SETTINGS_DENY,
|
||||
},
|
||||
|
||||
// ── Standard search crawlers ──────────────────────────────────────────
|
||||
{ userAgent: 'Googlebot', allow: '/' },
|
||||
{ userAgent: 'Bingbot', allow: '/' },
|
||||
{ userAgent: 'Slurp', allow: '/' }, // Yahoo
|
||||
{ userAgent: 'DuckDuckBot', allow: '/' },
|
||||
{ userAgent: 'YandexBot', allow: '/' },
|
||||
|
||||
// ── AI / LLM crawlers (GEO) ───────────────────────────────────────────
|
||||
// OpenAI — ChatGPT Browse + training
|
||||
{ userAgent: 'GPTBot', allow: '/', disallow: SETTINGS_DENY },
|
||||
{ userAgent: 'ChatGPT-User', allow: '/', disallow: SETTINGS_DENY },
|
||||
{ userAgent: 'OAI-SearchBot', allow: '/', disallow: SETTINGS_DENY },
|
||||
// Anthropic — Claude.ai + training (settings are already private so
|
||||
// we use a shorter deny list to let anthropic-ai see more content)
|
||||
{ userAgent: 'ClaudeBot', allow: '/', disallow: SETTINGS_DENY },
|
||||
{ userAgent: 'anthropic-ai', allow: '/', disallow: ['/api/', '/_next/'] },
|
||||
// Perplexity AI
|
||||
{ userAgent: 'PerplexityBot', allow: '/', disallow: SETTINGS_DENY },
|
||||
// Google — Gemini / AI Overviews / Bard training
|
||||
{ userAgent: 'Google-Extended', allow: '/', disallow: SETTINGS_DENY },
|
||||
{ userAgent: 'Googlebot-Extended', allow: '/', disallow: SETTINGS_DENY },
|
||||
// Meta AI (Llama, Meta AI assistant)
|
||||
{ userAgent: 'meta-externalagent', allow: '/', disallow: SETTINGS_DENY },
|
||||
{ userAgent: 'FacebookBot', allow: '/', disallow: SETTINGS_DENY },
|
||||
// Apple (Siri, AI features in Safari)
|
||||
{ userAgent: 'Applebot', allow: '/' },
|
||||
{ userAgent: 'Applebot-Extended', allow: '/', disallow: SETTINGS_DENY },
|
||||
// Cohere — Command R, enterprise LLMs
|
||||
{ userAgent: 'cohere-ai', allow: '/', disallow: SETTINGS_DENY },
|
||||
// Mistral / Le Chat
|
||||
{ userAgent: 'MistralAI-User', allow: '/', disallow: SETTINGS_DENY },
|
||||
// You.com AI search
|
||||
{ userAgent: 'YouBot', allow: '/', disallow: SETTINGS_DENY },
|
||||
// Brave AI (Leo assistant)
|
||||
{ userAgent: 'Brave', allow: '/' },
|
||||
// Common Crawl — feeds many open-source LLM training datasets
|
||||
{ userAgent: 'CCBot', allow: '/', disallow: SETTINGS_DENY },
|
||||
],
|
||||
sitemap: `${siteUrl}/sitemap.xml`,
|
||||
host: siteUrl,
|
||||
}
|
||||
}
|
||||
|
||||
export default function handler(
|
||||
_req: import('next').NextApiRequest,
|
||||
res: import('next').NextApiResponse,
|
||||
) {
|
||||
res.setHeader('Content-Type', 'text/plain')
|
||||
const data = robots()
|
||||
const rules = Array.isArray(data.rules) ? data.rules : [data.rules]
|
||||
res.send(
|
||||
rules
|
||||
.map(
|
||||
(r) =>
|
||||
'User-agent: ' +
|
||||
(r.userAgent ?? '*') +
|
||||
'\n' +
|
||||
[r.allow]
|
||||
.flat()
|
||||
.filter(Boolean)
|
||||
.map((p) => 'Allow: ' + p)
|
||||
.join('\n') +
|
||||
'\n' +
|
||||
[r.disallow]
|
||||
.flat()
|
||||
.filter(Boolean)
|
||||
.map((p) => 'Disallow: ' + p)
|
||||
.join('\n'),
|
||||
)
|
||||
.join('\n') +
|
||||
'\nSitemap: ' +
|
||||
data.sitemap,
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import type { MetadataRoute } from 'next'
|
||||
|
||||
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL
|
||||
|
||||
// In production, warn loudly but don't crash — the sitemap will use the
|
||||
// fallback URL. Set NEXT_PUBLIC_SITE_URL in your deployment env to get the
|
||||
// correct absolute URLs in sitemap.xml.
|
||||
if (!siteUrl && process.env.NODE_ENV === 'production') {
|
||||
console.warn(
|
||||
'[sitemap] NEXT_PUBLIC_SITE_URL is not set — sitemap will use https://trumpsignal.com as fallback. ' +
|
||||
'Set this env var in your deployment to avoid incorrect sitemap URLs.',
|
||||
)
|
||||
}
|
||||
|
||||
const base = (siteUrl || 'https://trumpsignal.com').replace(/\/$/, '')
|
||||
|
||||
const routes: Array<{
|
||||
path: string
|
||||
priority: number
|
||||
freq: MetadataRoute.Sitemap[number]['changeFrequency']
|
||||
}> = [
|
||||
{ path: '', priority: 1.0, freq: 'hourly' },
|
||||
{ path: '/trump', priority: 0.9, freq: 'hourly' },
|
||||
{ path: '/macro', priority: 0.9, freq: 'daily' },
|
||||
{ path: '/kol', priority: 0.9, freq: 'daily' },
|
||||
{ path: '/trades', priority: 0.8, freq: 'daily' },
|
||||
{ path: '/analytics', priority: 0.7, freq: 'daily' },
|
||||
{ path: '/methodology', priority: 0.8, freq: 'monthly' },
|
||||
{ path: '/glossary', priority: 0.8, freq: 'monthly' },
|
||||
{ path: '/case-studies', priority: 0.8, freq: 'monthly' },
|
||||
// NOTE: /settings is intentionally NOT listed — it's user-personalized and
|
||||
// robots.ts disallows it. Listing it here while disallowing in robots is a
|
||||
// self-contradicting signal to crawlers. Keep private pages out of both.
|
||||
{ path: '/privacy', priority: 0.3, freq: 'yearly' },
|
||||
{ path: '/terms', priority: 0.3, freq: 'yearly' },
|
||||
{ path: '/contact', priority: 0.4, freq: 'monthly' },
|
||||
]
|
||||
|
||||
// i18n shelved — only emit English routes. Add 'zh' back when content is
|
||||
// actually translated (otherwise Google flags duplicate content under hreflang).
|
||||
const locales = ['en']
|
||||
|
||||
function sitemap(): MetadataRoute.Sitemap {
|
||||
const now = new Date()
|
||||
const entries: MetadataRoute.Sitemap = []
|
||||
|
||||
// Root landing (not locale-scoped)
|
||||
entries.push({
|
||||
url: base,
|
||||
lastModified: now,
|
||||
changeFrequency: 'hourly',
|
||||
priority: 1.0,
|
||||
})
|
||||
|
||||
for (const locale of locales) {
|
||||
for (const r of routes) {
|
||||
entries.push({
|
||||
url: `${base}/${locale}${r.path}`,
|
||||
lastModified: now,
|
||||
changeFrequency: r.freq,
|
||||
priority: r.priority,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return entries
|
||||
}
|
||||
|
||||
export default function handler(
|
||||
_req: import('next').NextApiRequest,
|
||||
res: import('next').NextApiResponse,
|
||||
) {
|
||||
res.setHeader('Content-Type', 'application/xml')
|
||||
res.send(
|
||||
'<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' +
|
||||
sitemap()
|
||||
.map(
|
||||
(x) =>
|
||||
'<url><loc>' +
|
||||
String(x.url).replaceAll('&', '&').replaceAll('<', '<') +
|
||||
'</loc>' +
|
||||
(x.lastModified
|
||||
? '<lastmod>' +
|
||||
(x.lastModified instanceof Date
|
||||
? x.lastModified.toISOString()
|
||||
: String(x.lastModified)) +
|
||||
'</lastmod>'
|
||||
: '') +
|
||||
(x.changeFrequency ? '<changefreq>' + x.changeFrequency + '</changefreq>' : '') +
|
||||
(x.priority != null ? '<priority>' + x.priority + '</priority>' : '') +
|
||||
'</url>',
|
||||
)
|
||||
.join('') +
|
||||
'</urlset>',
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user