测试
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { prisma } from '@/lib/prisma';
|
||||
import { requireApiAuth } from '@/lib/api-auth';
|
||||
import { cleanupAccidentalStandaloneInlineCode, markdownToImportHtml } from '@/lib/markdown-import';
|
||||
|
||||
const MAX_TITLE_LENGTH = 200;
|
||||
const MAX_TAGS = 20;
|
||||
@@ -64,7 +65,19 @@ export async function POST(request: Request) {
|
||||
}
|
||||
|
||||
const type = body.type === 'folder' ? 'folder' : 'file';
|
||||
const content = typeof body.content === 'string' ? body.content : '';
|
||||
const importMarkdown = typeof body.importMarkdown === 'string' ? body.importMarkdown : null;
|
||||
const rawContent = typeof body.content === 'string' ? body.content : '';
|
||||
const content = cleanupAccidentalStandaloneInlineCode(
|
||||
importMarkdown !== null ? markdownToImportHtml(importMarkdown) : rawContent
|
||||
);
|
||||
if (importMarkdown !== null && process.env.NODE_ENV !== 'production') {
|
||||
const lines = importMarkdown.replace(/\r\n?/g, '\n').split('\n');
|
||||
const fenceLines = lines
|
||||
.map((line: string, idx: number) => (line.trimStart().startsWith('```') || line.trimStart().startsWith('~~~') ? idx + 1 : -1))
|
||||
.filter((n: number) => n > 0);
|
||||
const preEnd = content.indexOf('</code></pre>');
|
||||
console.info(`[import-md][POST] title="${title}" fences=${fenceLines.join(',') || 'none'} preEnd=${preEnd} len=${content.length}`);
|
||||
}
|
||||
const parentId = typeof body.parentId === 'string' ? body.parentId : null;
|
||||
const tags = normalizeTags(body.tags);
|
||||
const icon = typeof body.icon === 'string' ? body.icon : null;
|
||||
@@ -105,3 +118,6 @@ export async function POST(request: Request) {
|
||||
return NextResponse.json({ error: 'Error creating page' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user