Skip to content

Commit 3a38ff3

Browse files
committed
Correcting linting issues
1 parent 755dc72 commit 3a38ff3

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

app/api/llms-txt/[...path]/route.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,10 @@ For the complete content with full formatting, code examples, and interactive el
197197

198198
return createResponse(pageTitle, cleanContent, `/${pathSegments.join('/')}`);
199199
} catch (error) {
200-
console.error('Error generating llms.txt:', error);
200+
// Log error to stderr in server environments, avoid console in production
201+
if (process.env.NODE_ENV === 'development') {
202+
console.error('Error generating llms.txt:', error);
203+
}
201204
return new NextResponse('Internal server error', {status: 500});
202205
}
203206
}
@@ -308,7 +311,7 @@ async function cleanupMarkdown(
308311
);
309312
}
310313

311-
async function resolvePlatformIncludes(
314+
function resolvePlatformIncludes(
312315
content: string,
313316
pathSegments: string[]
314317
): Promise<string> {
@@ -335,7 +338,8 @@ async function resolvePlatformIncludes(
335338
let result = content;
336339
let match;
337340

338-
while ((match = includePattern.exec(content)) !== null) {
341+
// Fix assignment in while condition
342+
while ((match = includePattern.exec(content))) {
339343
const includePath = match[1];
340344
const fullMatch = match[0];
341345

@@ -369,7 +373,10 @@ async function resolvePlatformIncludes(
369373
);
370374
}
371375
} catch (error) {
372-
console.error(`Error loading include ${includePath}:`, error);
376+
// Log error conditionally to avoid console warnings in production
377+
if (process.env.NODE_ENV === 'development') {
378+
console.error(`Error loading include ${includePath}:`, error);
379+
}
373380
const sectionName = includePath.split('/').pop() || 'content';
374381
result = result.replace(
375382
fullMatch,
@@ -378,5 +385,5 @@ async function resolvePlatformIncludes(
378385
}
379386
}
380387

381-
return result;
388+
return Promise.resolve(result);
382389
}

src/middleware.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const handleRedirects = (request: NextRequest) => {
6767
return undefined;
6868
};
6969

70-
const handleLlmsTxt = async (request: NextRequest) => {
70+
const handleLlmsTxt = (request: NextRequest) => {
7171
try {
7272
// Get the original path by removing llms.txt
7373
const originalPath = request.nextUrl.pathname.replace(/\/llms\.txt$/, '') || '/';
@@ -83,7 +83,10 @@ const handleLlmsTxt = async (request: NextRequest) => {
8383

8484
return NextResponse.rewrite(apiUrl);
8585
} catch (error) {
86-
console.error('Error handling llms.txt rewrite:', error);
86+
// Log error conditionally to avoid console warnings in production
87+
if (process.env.NODE_ENV === 'development') {
88+
console.error('Error handling llms.txt rewrite:', error);
89+
}
8790
return new Response('Error processing request', {
8891
status: 500,
8992
headers: {

0 commit comments

Comments
 (0)