Skip to content

Commit 1182f2e

Browse files
committed
fix: appendchild related issue when redering content
1 parent 6f701ca commit 1182f2e

File tree

4 files changed

+24
-18
lines changed

4 files changed

+24
-18
lines changed

src/components/vertical-nav/project-nav.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@ export type RelatedLinks = [
1313

1414
export function projectInfo(about: AboutProject, links: RelatedLinks[]) {
1515
const navWrapper = document.getElementById('nav-wrapper');
16+
const section = document.createElement('section');
1617

17-
if (about != null && navWrapper != null) {
18-
navWrapper?.appendChild(sectionAboutTheGame(about));
18+
navWrapper?.appendChild(section);
1919

20+
if (typeof about === "object" && typeof links === "object") {
21+
section.appendChild(sectionAboutTheGame(about));
22+
section.appendChild(sectionRelatedLinks(links));
2023
}
21-
22-
if (links != null) {
23-
navWrapper?.appendChild(sectionRelatedLinks(links));
24+
else {
25+
throw new Error("Infos are not well formatted")
2426
}
2527

26-
return navWrapper;
28+
return section;
2729
}
2830

2931
//-----------------------------------------------------------------------
@@ -37,9 +39,9 @@ function sectionAboutTheGame(about: AboutProject) {
3739

3840
detailSection.className = "detail-section";
3941
detailTitle.textContent = "About the Project"
40-
releaseDate.textContent = "<b>Release date: </b>" + about.release;
41-
platformAvailable.textContent = "<b>Platforms: </b" + about.platforms;
42-
developerNames.textContent = "<b>Developer: </b>" + about.developer;
42+
releaseDate.innerHTML = "<b>Release date: </b>" + about.release;
43+
platformAvailable.innerHTML = "<b>Platforms: </b" + about.platforms;
44+
developerNames.innerHTML = "<b>Developer: </b>" + about.developer;
4345

4446
detailSection.appendChild(detailTitle);
4547
detailSection.appendChild(releaseDate);
@@ -52,9 +54,13 @@ function sectionAboutTheGame(about: AboutProject) {
5254

5355
function sectionRelatedLinks(relatedLinks: RelatedLinks[]) {
5456
const detailSection = document.createElement('div');
57+
const detailTitle = document.createElement("h4");
5558
const linkList = document.createElement('ul');
5659

5760
detailSection.className = "detail-section";
61+
detailTitle.textContent = "Related Links";
62+
63+
detailSection.appendChild(detailTitle);
5864
detailSection.appendChild(linkList);
5965

6066
relatedLinks.forEach(relatedLink => {

src/content/projects/tank/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import SCREENSHOT_4 from "./assets/tank-screenshot-4.jpg"
1414
const content: ProjectContent = {
1515
name: "TANK",
1616
tagline: "A collection of three unique iterations",
17-
path: "www.charlesdouce.com/interactives/",
17+
path: "www.charlesdoucet.com/interactives/",
1818

1919
paragraphs: [
2020
"TANK assemble three different games, each based on the original TANKS! game made by Unity Technologies. It’s an exploration of mechanics and the discovery of new environment. The game is experimental and has the goal to dig the player’s curiosity. Prepare yourself as you step into unknown territory, revealing the ruins of a lost civilization.",

src/views/project-view/index.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,24 @@ export type ProjectContent = {
2020

2121
export function projectView(content: ProjectContent) {
2222
const viewWrapper = document.getElementById('view-wrapper')!;
23+
const article = document.createElement('article');
2324

2425
const projectTitle = writeTitle("h1", content.name);
2526
const projectShowcase = createVideoShowcase(content.heroVideo);
2627
const projectSubtitle = writeTitle("h2", content.tagline)
2728

28-
viewWrapper.appendChild(projectTitle);
29-
viewWrapper.appendChild(projectShowcase);
30-
viewWrapper.appendChild(projectSubtitle);
29+
viewWrapper.appendChild(article);
30+
article.appendChild(projectTitle);
31+
article.appendChild(projectShowcase);
32+
article.appendChild(projectSubtitle);
3133

3234
content.paragraphs.forEach(paragraph => {
3335
const text = writeParagraph(paragraph);
34-
viewWrapper.appendChild(text);
36+
article.appendChild(text);
3537
})
3638

3739
const projectGallery = createContentGallery(content.imageGallery);
38-
viewWrapper.appendChild(projectGallery);
40+
article.appendChild(projectGallery);
3941

40-
return viewWrapper;
42+
return article;
4143
}

src/views/utils/view-utils.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ export function renderView(viewFn: Function) {
1818
const viewWrapper = clearView();
1919
const view = viewFn();
2020

21-
console.log(typeof view);
22-
2321
viewWrapper.appendChild(view);
2422
}
2523

0 commit comments

Comments
 (0)