-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject.js
30 lines (26 loc) · 1.39 KB
/
project.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
document.addEventListener('DOMContentLoaded', function() {
const params = new URLSearchParams(window.location.search);
const projectId = params.get('id');
fetch('../data/projects.json')
.then(response => response.json())
.then(projects => {
const project = projects.projects.find(p => p.id.toString() === projectId);
if (project) {
document.title += ' - ' + project.title;
const detailSection = document.getElementById('body');
let content = `<h1>${project.title}</h1>
<p><b>Dates worked on:</b> ${project.date}</p>
<p><b>Motivation:</b> ${project.motivation}</p>`;
if(project.tech.length > 0) content += `<p><b>Technology:</b> ${project.tech}</p>`;
if(project.link.length > 0) content += `<p><b>Link:</b> <a href="${project.link}">${project.link}</a></p>`;
if(project.repo.length > 0) content += `<p><b>Repository:</b> <a href="${project.repo}">${project.repo}</a></p>`;
content += `<h2>Blog</h2>`;
project.body.forEach(element => {
content += `${element}`;
});
detailSection.innerHTML = content;
} else {
document.getElementById('body').innerHTML = '<p>Project not found.</p>';
}
});
});