Add folder and post details fetching in ManagePage; implement delete confirmation modal for folders with recursive deletion option in API.
This commit is contained in:
18
src/app/api/admin/posts/size/route.ts
Normal file
18
src/app/api/admin/posts/size/route.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const postsDirectory = path.join(process.cwd(), 'posts');
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const slug = searchParams.get('slug');
|
||||
if (!slug) return NextResponse.json({ size: null, created: null });
|
||||
try {
|
||||
const filePath = path.join(postsDirectory, `${slug}.md`);
|
||||
const stat = fs.statSync(filePath);
|
||||
return NextResponse.json({ size: stat.size, created: stat.birthtime.toISOString() });
|
||||
} catch {
|
||||
return NextResponse.json({ size: null, created: null });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user