Major changes

This commit is contained in:
owenqwenstarsky
2026-01-24 16:52:19 -06:00
parent 011e40119d
commit 7181791734
46 changed files with 8371 additions and 127 deletions
+34
View File
@@ -0,0 +1,34 @@
import { NextRequest, NextResponse } from 'next/server';
export async function GET(request: NextRequest) {
const baseUrl = request.nextUrl.origin;
try {
const response = await fetch(
'https://en.wikipedia.org/api/rest_v1/page/random/summary',
{
headers: {
'User-Agent': 'WikiPlus/1.0',
},
}
);
if (!response.ok) {
throw new Error('Failed to fetch from Wikipedia API');
}
const data = await response.json();
// Convert title to URL-friendly format (replace spaces with underscores)
const urlTitle = data.title.replace(/ /g, '_');
return NextResponse.redirect(
new URL(`/summary/${encodeURIComponent(urlTitle)}`, baseUrl)
);
} catch (error) {
console.error('Error fetching random article:', error);
return NextResponse.redirect(
new URL('/?error=failed', baseUrl)
);
}
}