Skip to content
Merged

Main #11

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
15 changes: 10 additions & 5 deletions src/app/rss.xml/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ function escapeXml(value: string): string {
}

export async function GET() {
const supabase = await createClient();
const { items } = await fetchNewsList(supabase, {
page: 1,
pageSize: 30,
}).catch(() => ({ items: [], total: 0, page: 1, pageSize: 30 }));
let items: Awaited<ReturnType<typeof fetchNewsList>>['items'] = [];
try {
const supabase = await createClient();
({ items } = await fetchNewsList(supabase, {
page: 1,
pageSize: 30,
}).catch(() => ({ items: [], total: 0, page: 1, pageSize: 30 })));
} catch {
items = [];
}

const rssItems = items
.map((article) => {
Expand Down
29 changes: 17 additions & 12 deletions src/app/sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,6 @@ import { absoluteUrl } from '@/lib/url';
export const revalidate = 86400;

export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const supabase = await createClient();

const [news, reviews] = await Promise.all([
fetchNewsList(supabase, { page: 1, pageSize: 200 }).catch(() => ({
items: [],
total: 0,
page: 1,
pageSize: 200,
})),
fetchMonthlyReviews(supabase).catch(() => []),
]);

const staticEntries: MetadataRoute.Sitemap = [
{ url: siteConfig.url, lastModified: new Date(), priority: 1 },
{ url: absoluteUrl('/news'), lastModified: new Date(), priority: 0.9 },
Expand All @@ -35,6 +23,23 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
{ url: absoluteUrl('/authors'), lastModified: new Date(), priority: 0.5 },
];

let supabase;
try {
supabase = await createClient();
} catch {
return staticEntries;
}

const [news, reviews] = await Promise.all([
fetchNewsList(supabase, { page: 1, pageSize: 200 }).catch(() => ({
items: [],
total: 0,
page: 1,
pageSize: 200,
})),
fetchMonthlyReviews(supabase).catch(() => []),
]);

const newsEntries: MetadataRoute.Sitemap = news.items.map((article) => ({
url: absoluteUrl(`/news/${article.slug}`),
lastModified: new Date(article.updatedAt ?? article.publishedAt),
Expand Down
2 changes: 1 addition & 1 deletion src/middleware.ts β†’ src/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { NextRequest } from 'next/server';
import { updateSession } from '@/lib/supabase/middleware';

export async function middleware(request: NextRequest) {
export async function proxy(request: NextRequest) {
return updateSession(request);
}

Expand Down
Loading