This commit is contained in:
@@ -51,12 +51,17 @@ export async function GET(request: Request) {
|
||||
// Return the current pinned.json object
|
||||
try {
|
||||
const pinnedPath = path.join(postsDirectory, 'pinned.json');
|
||||
console.log('Reading pinned.json from:', pinnedPath);
|
||||
let pinnedData = { pinned: [], folderEmojis: {} };
|
||||
if (fs.existsSync(pinnedPath)) {
|
||||
pinnedData = JSON.parse(fs.readFileSync(pinnedPath, 'utf8'));
|
||||
console.log('Successfully read pinned.json with data:', pinnedData);
|
||||
} else {
|
||||
console.log('pinned.json does not exist, using default data');
|
||||
}
|
||||
return NextResponse.json(pinnedData);
|
||||
} catch (error) {
|
||||
console.error('Error reading pinned.json:', error);
|
||||
return NextResponse.json({ error: 'Error reading pinned.json' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
@@ -69,7 +74,10 @@ export async function PATCH(request: Request) {
|
||||
return NextResponse.json({ error: 'Invalid pinned or folderEmojis data' }, { status: 400 });
|
||||
}
|
||||
const pinnedPath = path.join(postsDirectory, 'pinned.json');
|
||||
console.log('Saving pinned.json to:', pinnedPath);
|
||||
console.log('Saving data:', { pinned, folderEmojis });
|
||||
fs.writeFileSync(pinnedPath, JSON.stringify({ pinned, folderEmojis }, null, 2), 'utf8');
|
||||
console.log('Successfully saved pinned.json');
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
console.error('Error updating pinned.json:', error);
|
||||
|
||||
Reference in New Issue
Block a user