Skip to content

Commit b9d319f

Browse files
committed
🎉: Update Scripts
1 parent c09bb20 commit b9d319f

File tree

4 files changed

+104
-14
lines changed

4 files changed

+104
-14
lines changed

‎src/data.js‎

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Generating Pages
2+
export const pages = [
3+
{
4+
title: "Leat Sophat - Portfolio",
5+
name: "Home",
6+
route: "home",
7+
description: "Welcome to my portfolio - Thoughts from a wandering mind. I am the senior front-end developer of TurboTech, and an UI/UX designer. In my free time, I like design side projects and developing them."
8+
},
9+
{
10+
title: "Leat Sophat | Projects",
11+
name: "Projects",
12+
route: "projects",
13+
description: "Showing projects that I have built."
14+
},
15+
{
16+
title: "Leat Sophat | About",
17+
name: "About Me",
18+
route: "about",
19+
description: "About my background. I am Leat Sophat. I'm a Senior Front-end Developer as TURBOTECH CO.,LTD. I from Phnome Penh, Cambodia. ..."
20+
},
21+
{
22+
title: "Leat Sophat | Hiring",
23+
name: "Hire Me",
24+
route: "hire-me",
25+
description: "Checkout my curriculum vitae"
26+
},
27+
{
28+
title: "Leat Sophat | Not Found",
29+
name: "Not Found",
30+
route: "404",
31+
description: "Sorry! This page is not available."
32+
},
33+
{
34+
title: "Leat Sophat | FireWorks",
35+
name: "FireWorks",
36+
route: "fireworks",
37+
description: "Sample fireworks"
38+
},
39+
{
40+
title: "Leat Sophat | FireWorks",
41+
name: "FireWorks",
42+
route: "contact",
43+
description: "Sample fireworks"
44+
},
45+
]
46+
47+
48+
// Main Menu
49+
export const modules = [
50+
// {
51+
// title: "Leat Sophat - Portfolio",
52+
// name: "Home",
53+
// route: "home",
54+
// description: "Welcome to my portfolio - Thoughts from a wandering mind. I am the senior front-end developer of TurboTech, and an UI/UX designer. In my free time, I like design side projects and developing them."
55+
// },
56+
{
57+
title: "Leat Sophat | Projects",
58+
name: "Projects",
59+
route: "projects",
60+
description: "Showing projects that I have built."
61+
},
62+
{
63+
title: "Leat Sophat | Contact Me",
64+
name: "Contact Me",
65+
route: "contact",
66+
description: "Sample fireworks"
67+
},
68+
{
69+
title: "Leat Sophat | About",
70+
name: "About Me",
71+
route: "about",
72+
description: "About my background. I am Leat Sophat. I'm a Senior Front-end Developer as TURBOTECH CO.,LTD. I from Phnome Penh, Cambodia. ..."
73+
},
74+
{
75+
title: "Leat Sophat | Hiring",
76+
name: "Hire Me",
77+
route: "hire-me",
78+
description: "Checkout my curriculum vitae"
79+
},
80+
]

‎src/header.js‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { modules as pages } from "../data/pages.config"
2-
import { minify } from "../helpers/stringMinify"
1+
import { modules as pages } from "./data.js"
2+
import { minify } from "./minify.js"
33
export class Header {
44

55
constructor() {
@@ -136,14 +136,18 @@ export class Header {
136136
* Main Header Navigation
137137
*/
138138
#navigation = () => {
139-
const header = document.querySelector('#header')
140-
header.innerHTML = minify(`
139+
try {
140+
const header = document.querySelector('#header')
141+
header.innerHTML = minify(`
141142
<nav class="flex items-center justify-between w-full max-w-6xl mx-auto">
142143
${this.#logo()}
143144
${this.#menu()}
144145
${this.#rightNavigation()}
145146
</nav>
146147
`)
148+
} catch (error) {
149+
150+
}
147151
}
148152
}
149153

‎src/index.js‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1+
import { Header, sidebar } from "./header.js"
2+
import { renderCanvas } from "./render-canvas.js"
13

2-
import { Header, sidebar, toggleTheme } from "./header.js";
3-
import { renderCanvas } from "./render-canvas.js";
4-
5-
4+
// document.querySelector('[data-image]').innerHTML = showProfile(fav512)
5+
const buttonToggle = document.querySelectorAll('[data-toggle]')
66
document.addEventListener('DomContentLoaded', new Header())
7-
document.addEventListener('DomContentLoaded', codingWith())
7+
document.addEventListener('DomContentLoaded', Array.from(buttonToggle).forEach(button => button.addEventListener('click', toggleTheme)))
88
document.addEventListener('DomContentLoaded', sidebar())
99
document.addEventListener('DomContentLoaded', renderCanvas())
10-
11-
12-
if (typeof window !== "undefined") {
13-
window.renderCanvas = renderCanvas
14-
}

‎src/minify.js‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export const minify = (string) => {
2+
if (!string) return ''
3+
4+
return String(string)
5+
.replace(/\s+/g, ' ') // Convert multiple spaces to single space
6+
.replace(/>\s+</g, '><') // Remove spaces between HTML tags
7+
.replace(/\n/g, '') // Remove newlines
8+
.replace(/\r/g, '') // Remove carriage returns
9+
.replace(/\t/g, '') // Remove tabs
10+
.trim() // Remove leading/trailing whitespace
11+
}

0 commit comments

Comments
 (0)