Skip to content

Commit 3cca410

Browse files
maybe build errors fixed now
1 parent 5fde287 commit 3cca410

File tree

2 files changed

+37
-15
lines changed

2 files changed

+37
-15
lines changed

config/pastProjects.json

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@
44
"label": "Codenames"
55
},
66
{
7-
"label": "LLM Augmentation"
7+
"label": "LLM Augmentation",
8+
"github": "https://github.com/MichiganDataScienceTeam/W24-llm-augmentation"
89
},
910
{
1011
"label": "Poker Bot"
1112
},
1213
{
13-
"label": "Rate My Professor Sentiment Analysis"
14+
"label": "RMP Sentiment Analysis",
15+
"github": "https://github.com/MichiganDataScienceTeam/WN2024-RMP"
1416
},
1517
{
16-
"label": "Real vs Fake Faces"
18+
"label": "Real vs Fake Faces",
19+
"github": "https://github.com/MichiganDataScienceTeam/W24-RvF"
1720
},
1821
{
1922
"label": "Shazam Clone"
@@ -22,10 +25,12 @@
2225
"label": "Spotify Analysis"
2326
},
2427
{
25-
"label": "Stock Market Analysis"
28+
"label": "Stock Market Analysis",
29+
"github": "https://github.com/MichiganDataScienceTeam/W24-StockAnalysis"
2630
},
2731
{
28-
"label": "TikTok Videos"
32+
"label": "TikTok Videos",
33+
"github": "https://github.com/MichiganDataScienceTeam/W24-TikTokVideos"
2934
}
3035
],
3136
"Fall 2023": [
@@ -45,16 +50,19 @@
4550
"label": "NHANES"
4651
},
4752
{
48-
"label": "Real vs Photoshopped Faces"
53+
"label": "Real vs Fake Faces",
54+
"github": "F23-RvF"
4955
},
5056
{
51-
"label": "Reinforcement Learning"
57+
"label": "Reinforcement Learning",
58+
"github": "https://github.com/MichiganDataScienceTeam/F23-Reinforcement-Learning"
5259
},
5360
{
5461
"label": "Sentence Completer"
5562
},
5663
{
57-
"label": "Webscraping"
64+
"label": "Webscraping",
65+
"github": "https://github.com/MichiganDataScienceTeam/F23-Webscraping"
5866
}
5967
],
6068
"Winter 2023": [
@@ -106,7 +114,7 @@
106114
"label": "Pokemon Data Science"
107115
},
108116
{
109-
"label": "SEC Insider Information",
117+
"label": "SEC Insider Trading",
110118
"github": "https://github.com/MichiganDataScienceTeam/F22-SEC-Insider-Trading"
111119
},
112120
{

pages/projects/[...slug].jsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ import Hero from "@/components/hero";
77
import Image from "next/image";
88
import HeadContent from "@/components/headContent";
99

10+
// Function to get all projects from JSON files
11+
const getAllProjects = () => {
12+
const pastProjects = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'config', 'pastProjects.json'), 'utf-8'));
13+
const currentProjects = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'config', 'currentProjects.json'), 'utf-8'));
14+
return [...pastProjects, ...currentProjects];
15+
};
16+
1017
function ProjectPage({ content, title, images }) {
1118
const router = useRouter();
1219
const basePath = router.basePath;
@@ -29,7 +36,14 @@ function ProjectPage({ content, title, images }) {
2936
}
3037

3138
export async function getStaticProps({ params }) {
39+
const allProjects = getAllProjects();
3240
const [subdirectory, innerDir] = params.slug;
41+
const project = allProjects.find(proj => proj.subdirectory === subdirectory && proj.innerDir === innerDir);
42+
43+
if (!project) {
44+
return { notFound: true };
45+
}
46+
3347
const filePath = path.join(process.cwd(), 'content', 'projects', subdirectory, innerDir, 'writeup.md');
3448
const fileContent = fs.readFileSync(filePath, 'utf-8');
3549

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

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

52-
const paths = subdirectories.flatMap(subdirectory => {
53-
const innerDirectories = fs.readdirSync(path.join(projectsDirectory, subdirectory.name), { withFileTypes: true }).filter(dirent => dirent.isDirectory());
54-
return innerDirectories.map(innerDir => ({ params: { slug: [subdirectory.name, innerDir.name] } }));
55-
});
65+
const paths = allProjects.map(project => ({
66+
params: {
67+
slug: [project.subdirectory, project.innerDir],
68+
},
69+
}));
5670

5771
return {
5872
paths,

0 commit comments

Comments
 (0)