site/middleware.js
DevIos01 1a7d5f2706 Redirecting To New Donation / Philanthropy Page
as requested by @zachlatta in #hq in Slack, this deleted donate.js aka the page, and adding a redirect logic on middleware, also changed from any mdx file if there was any to the new link
2024-01-03 05:23:53 +01:00

22 lines
638 B
JavaScript

import { NextResponse } from 'next/server'
import country from 'country-list-js'
const partners = ['gb_help_desk']
export function middleware(request) {
if (request.nextUrl.pathname.startsWith('/slack')) {
let continent = country.findByIso2(request.geo.country || 'AU').continent
if (continent === 'Oceania') {
continent = 'Australia'
}
const response = NextResponse.next()
response.cookies.set('continent', continent || '')
return response
}
if (request.nextUrl.pathname === '/donate/') {
return NextResponse.redirect('https://hackclub.com/philanthropy/');
}
return NextResponse.next();
}