feat: add cookie consent banner and privacy policy page; update dependencies and improve animations
This commit is contained in:
@@ -4,23 +4,31 @@ import path from 'path';
|
||||
import matter from 'gray-matter';
|
||||
|
||||
export async function GET() {
|
||||
const projectsDirectory = path.join(process.cwd(), 'public/projects');
|
||||
const filenames = fs.readdirSync(projectsDirectory);
|
||||
try {
|
||||
const projectsDirectory = path.join(process.cwd(), 'public/projects');
|
||||
const filenames = fs.readdirSync(projectsDirectory);
|
||||
|
||||
console.log('Filenames:', filenames);
|
||||
const projects = filenames
|
||||
.filter((filename) => {
|
||||
const filePath = path.join(projectsDirectory, filename);
|
||||
return fs.statSync(filePath).isFile();
|
||||
})
|
||||
.map((filename) => {
|
||||
const filePath = path.join(projectsDirectory, filename);
|
||||
const fileContents = fs.readFileSync(filePath, 'utf8');
|
||||
const {data} = matter(fileContents);
|
||||
|
||||
const projects = filenames.map((filename) => {
|
||||
const filePath = path.join(projectsDirectory, filename);
|
||||
const fileContents = fs.readFileSync(filePath, 'utf8');
|
||||
const {data} = matter(fileContents);
|
||||
return {
|
||||
id: data.id,
|
||||
title: data.title,
|
||||
description: data.description,
|
||||
slug: filename.replace('.md', ''),
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
id: data.id,
|
||||
title: data.title,
|
||||
description: data.description,
|
||||
slug: filename.replace('.md', ''),
|
||||
};
|
||||
});
|
||||
|
||||
return NextResponse.json(projects);
|
||||
return NextResponse.json(projects);
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch projects:", error);
|
||||
return NextResponse.json({error: 'Failed to fetch projects'}, {status: 500});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user