Skip to content

Commit

Permalink
maybe build errors fixed now
Browse files Browse the repository at this point in the history
  • Loading branch information
izzyg770 committed Jul 29, 2024
1 parent 5fde287 commit 3cca410
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 15 deletions.
26 changes: 17 additions & 9 deletions config/pastProjects.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
"label": "Codenames"
},
{
"label": "LLM Augmentation"
"label": "LLM Augmentation",
"github": "https://github.com/MichiganDataScienceTeam/W24-llm-augmentation"
},
{
"label": "Poker Bot"
},
{
"label": "Rate My Professor Sentiment Analysis"
"label": "RMP Sentiment Analysis",
"github": "https://github.com/MichiganDataScienceTeam/WN2024-RMP"
},
{
"label": "Real vs Fake Faces"
"label": "Real vs Fake Faces",
"github": "https://github.com/MichiganDataScienceTeam/W24-RvF"
},
{
"label": "Shazam Clone"
Expand All @@ -22,10 +25,12 @@
"label": "Spotify Analysis"
},
{
"label": "Stock Market Analysis"
"label": "Stock Market Analysis",
"github": "https://github.com/MichiganDataScienceTeam/W24-StockAnalysis"
},
{
"label": "TikTok Videos"
"label": "TikTok Videos",
"github": "https://github.com/MichiganDataScienceTeam/W24-TikTokVideos"
}
],
"Fall 2023": [
Expand All @@ -45,16 +50,19 @@
"label": "NHANES"
},
{
"label": "Real vs Photoshopped Faces"
"label": "Real vs Fake Faces",
"github": "F23-RvF"
},
{
"label": "Reinforcement Learning"
"label": "Reinforcement Learning",
"github": "https://github.com/MichiganDataScienceTeam/F23-Reinforcement-Learning"
},
{
"label": "Sentence Completer"
},
{
"label": "Webscraping"
"label": "Webscraping",
"github": "https://github.com/MichiganDataScienceTeam/F23-Webscraping"
}
],
"Winter 2023": [
Expand Down Expand Up @@ -106,7 +114,7 @@
"label": "Pokemon Data Science"
},
{
"label": "SEC Insider Information",
"label": "SEC Insider Trading",
"github": "https://github.com/MichiganDataScienceTeam/F22-SEC-Insider-Trading"
},
{
Expand Down
26 changes: 20 additions & 6 deletions pages/projects/[...slug].jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ import Hero from "@/components/hero";
import Image from "next/image";
import HeadContent from "@/components/headContent";

// Function to get all projects from JSON files
const getAllProjects = () => {
const pastProjects = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'config', 'pastProjects.json'), 'utf-8'));
const currentProjects = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'config', 'currentProjects.json'), 'utf-8'));
return [...pastProjects, ...currentProjects];
};

function ProjectPage({ content, title, images }) {
const router = useRouter();
const basePath = router.basePath;
Expand All @@ -29,7 +36,14 @@ function ProjectPage({ content, title, images }) {
}

export async function getStaticProps({ params }) {
const allProjects = getAllProjects();
const [subdirectory, innerDir] = params.slug;
const project = allProjects.find(proj => proj.subdirectory === subdirectory && proj.innerDir === innerDir);

if (!project) {
return { notFound: true };
}

const filePath = path.join(process.cwd(), 'content', 'projects', subdirectory, innerDir, 'writeup.md');
const fileContent = fs.readFileSync(filePath, 'utf-8');

Expand All @@ -46,13 +60,13 @@ export async function getStaticProps({ params }) {
}

export async function getStaticPaths() {
const projectsDirectory = path.join(process.cwd(), "content", "projects");
const subdirectories = fs.readdirSync(projectsDirectory, { withFileTypes: true }).filter(dirent => dirent.isDirectory());
const allProjects = getAllProjects();

const paths = subdirectories.flatMap(subdirectory => {
const innerDirectories = fs.readdirSync(path.join(projectsDirectory, subdirectory.name), { withFileTypes: true }).filter(dirent => dirent.isDirectory());
return innerDirectories.map(innerDir => ({ params: { slug: [subdirectory.name, innerDir.name] } }));
});
const paths = allProjects.map(project => ({
params: {
slug: [project.subdirectory, project.innerDir],
},
}));

return {
paths,
Expand Down

0 comments on commit 3cca410

Please sign in to comment.