Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion scripts/validate-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ function buildValidPaths(): Set<string> {
paths.add(p)
}

// App routes (behind auth / mobile-ui) — content may link to these
for (const p of [
'/profile',
'/profile/backup',
'/profile/edit',
'/profile/exchange-rate',
'/profile/identity-verification',
'/home',
'/send',
'/request',
'/settings',
'/history',
'/points',
'/recover-funds',
]) {
paths.add(p)
}

const countrySlugs = listDirs(path.join(CONTENT_DIR, 'countries'))
const competitorSlugs = listDirs(path.join(CONTENT_DIR, 'compare'))
const payWithSlugs = listDirs(path.join(CONTENT_DIR, 'pay-with'))
Expand Down Expand Up @@ -187,6 +205,30 @@ function isInternalLink(url: string): boolean {
return true
}

// --- Frontmatter parsing ---

function parseFrontmatter(content: string): Record<string, unknown> {
const match = content.match(/^---\n([\s\S]*?)\n---/)
if (!match) return {}
const frontmatter: Record<string, unknown> = {}
for (const line of match[1].split('\n')) {
const colonIdx = line.indexOf(':')
if (colonIdx === -1) continue
const key = line.slice(0, colonIdx).trim()
const value = line.slice(colonIdx + 1).trim()
if (value === 'true') frontmatter[key] = true
else if (value === 'false') frontmatter[key] = false
else frontmatter[key] = value
}
return frontmatter
}

function isPublished(content: string): boolean {
const fm = parseFrontmatter(content)
// If published is explicitly false, skip the file
return fm.published !== false
}

// --- Scan content files ---

function getAllMdFiles(dir: string): string[] {
Expand Down Expand Up @@ -225,8 +267,17 @@ function main() {
const broken: BrokenLink[] = []
let totalLinks = 0

let skippedUnpublished = 0

for (const file of files) {
const content = fs.readFileSync(file, 'utf-8')

// Skip unpublished/draft content — links to not-yet-built routes are expected
if (!isPublished(content)) {
skippedUnpublished++
continue
}

const links = extractLinks(content)
totalLinks += links.length

Expand All @@ -246,7 +297,10 @@ function main() {
}

// --- Report ---
console.log(`Checked ${totalLinks} internal links across ${files.length} files\n`)
if (skippedUnpublished > 0) {
console.log(` Skipped ${skippedUnpublished} unpublished files\n`)
}
console.log(`Checked ${totalLinks} internal links across ${files.length - skippedUnpublished} published files\n`)

if (broken.length === 0) {
console.log('✓ No broken internal links found!')
Expand Down
162 changes: 67 additions & 95 deletions src/components/LandingPage/SEOFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,112 +1,84 @@
import Link from 'next/link'
import footerManifest from '@/content/generated/footer-manifest.json'

// Curated "seed list" for Google crawl discovery. Renders below the main footer
// on non-marketing pages (homepage, /exchange, /lp, etc.). Marketing pages don't
// need this — they already have RelatedPages + CountryGrid linking to sibling content.
// SEO footer driven by peanut-content's generated/footer-manifest.json.
// To update: add `featured: true` to content frontmatter, run
// `node scripts/generate-footer-manifest.js` in peanut-content, and deploy.
//
// Data is inlined (not imported from @/data/seo) because Footer.tsx is bundled
// by webpack for client-routed pages (e.g. /exchange) — importing fs-dependent
// modules would break the build.
//
// IMPORTANT: Only list slugs that have published content in peanut-content.
// The validate-links CI in peanut-content catches broken internal links, but
// this file lives in peanut-ui — verify manually when editing.
// JSON import is webpack-safe for client bundles (no fs dependency).

interface FooterLink {
slug: string
name: string
href: string
external?: boolean
}

const linkClass = 'text-xs text-white underline hover:text-white/70'

function FooterColumn({ title, children }: { title: string; children: React.ReactNode }) {
return (
<div>
<h3 className="mb-3 text-xs font-bold text-white">{title}</h3>
<ul className="space-y-1">{children}</ul>
</div>
)
}

const TOP_COUNTRIES: Array<{ slug: string; name: string }> = [
{ slug: 'argentina', name: 'Argentina' },
{ slug: 'brazil', name: 'Brazil' },
{ slug: 'mexico', name: 'Mexico' },
{ slug: 'colombia', name: 'Colombia' },
{ slug: 'philippines', name: 'Philippines' },
{ slug: 'nigeria', name: 'Nigeria' },
{ slug: 'india', name: 'India' },
{ slug: 'chile', name: 'Chile' },
]
function FooterLink({ link, prefix }: { link: FooterLink; prefix?: string }) {
const label = prefix ? `${prefix} ${link.name}` : link.name

const COMPETITORS: Array<{ slug: string; name: string }> = [
{ slug: 'wise', name: 'Wise' },
{ slug: 'western-union', name: 'Western Union' },
{ slug: 'paypal', name: 'PayPal' },
{ slug: 'revolut', name: 'Revolut' },
{ slug: 'binance-p2p', name: 'Binance P2P' },
]
if (link.external) {
return (
<li>
<a href={link.href} className={linkClass} target="_blank" rel="noopener noreferrer">
{label}
</a>
</li>
)
}

const EXCHANGES: Array<{ slug: string; name: string }> = [
{ slug: 'binance', name: 'Binance' },
{ slug: 'coinbase', name: 'Coinbase' },
{ slug: 'bybit', name: 'Bybit' },
{ slug: 'kraken', name: 'Kraken' },
]
return (
<li>
<Link href={link.href} className={linkClass}>
{label}
</Link>
</li>
)
}

export function SEOFooter() {
const { sendMoney, compare, articles, resources } = footerManifest

return (
<nav aria-label="Site directory" className="bg-black px-8 py-8 md:px-20">
<div className="flex flex-wrap justify-between gap-y-8">
<div>
<h3 className="mb-3 text-xs font-bold text-white">Send Money</h3>
<ul className="space-y-1">
{TOP_COUNTRIES.map(({ slug, name }) => (
<li key={slug}>
<Link
href={`/en/send-money-to/${slug}`}
className="text-xs text-white underline hover:text-white/70"
>
Send to {name}
</Link>
</li>
))}
</ul>
</div>
<FooterColumn title="Send Money">
{(sendMoney.to as FooterLink[]).map((link) => (
<FooterLink key={link.slug} link={link} prefix="Send to" />
))}
{(sendMoney.from as FooterLink[]).map((link) => (
<FooterLink key={link.slug} link={link} prefix="Send from" />
))}
</FooterColumn>

<div>
<h3 className="mb-3 text-xs font-bold text-white">Countries</h3>
<ul className="space-y-1">
{TOP_COUNTRIES.map(({ slug, name }) => (
<li key={slug}>
<Link href={`/en/${slug}`} className="text-xs text-white underline hover:text-white/70">
Peanut in {name}
</Link>
</li>
))}
</ul>
</div>
<FooterColumn title="Compare">
{(compare as FooterLink[]).map((link) => (
<FooterLink key={link.slug} link={link} prefix="Peanut vs" />
))}
</FooterColumn>

<div>
<h3 className="mb-3 text-xs font-bold text-white">Compare</h3>
<ul className="space-y-1">
{COMPETITORS.map(({ slug, name }) => (
<li key={slug}>
<Link
href={`/en/compare/peanut-vs-${slug}`}
className="text-xs text-white underline hover:text-white/70"
>
Peanut vs {name}
</Link>
</li>
))}
</ul>
</div>
<FooterColumn title="Articles">
{(articles as FooterLink[]).map((link) => (
<FooterLink key={link.slug} link={link} />
))}
</FooterColumn>

<div>
<h3 className="mb-3 text-xs font-bold text-white">Resources</h3>
<ul className="space-y-1">
<li>
<Link href="/en/help" className="text-xs text-white underline hover:text-white/70">
Help Center
</Link>
</li>
{EXCHANGES.map(({ slug, name }) => (
<li key={slug}>
<Link
href={`/en/deposit/from-${slug}`}
className="text-xs text-white underline hover:text-white/70"
>
Deposit from {name}
</Link>
</li>
))}
</ul>
</div>
<FooterColumn title="Resources">
{(resources as FooterLink[]).map((link) => (
<FooterLink key={link.slug} link={link} />
))}
</FooterColumn>
</div>
</nav>
)
Expand Down
2 changes: 1 addition & 1 deletion src/content
Loading