Skip to content

Commit 2f98991

Browse files
committed
github path upgrade
1 parent 2ec1925 commit 2f98991

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

โ€Žmoto ride.jsโ€Ž

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,20 @@ function changeCatalogMenueFunction(event) {
8282

8383
//?: ื”ืฉืžื” ืฉืœ ืื™ืจื•ืข ืฉืžืจืขื ืŸ ืืช ื”ื“ืคื™ื
8484
document.addEventListener('DOMContentLoaded', () => {
85+
// ื”ื—ืœืฃ ืœึพusername ื•ึพrepo ืฉืœืš
86+
const githubUsername = 'shaialt';
87+
const githubRepo = 'Moto-Ride';
88+
89+
// ื‘ื•ื“ืง ืื ืื ื—ื ื• ื‘ึพGitHub Pages ืœืคื™ ื”-hostname (ืืคืฉืจ ืœื”ืชืื™ื ืœืคื™ ื”ืฆื•ืจืš)
90+
const isGitHubPages = window.location.hostname === `${githubUsername}.github.io`;
91+
92+
// ืžื’ื“ื™ืจ ืืช ื‘ืกื™ืก ื”ื ืชื™ื‘ ืœืคื™ ื”ืกื‘ื™ื‘ื”:
93+
// ืื GitHub Pages: /repo-name/
94+
// ืื—ืจืช (ืœื™ื™ื‘ ืกืจื‘ืจ ืžืงื•ืžื™ ืื• ืกื‘ื™ื‘ื” ืื—ืจืช): ../
95+
const basePath = isGitHubPages ? `/${githubRepo}/` : '../';
96+
8597
//?: ื”ื›ื ืกืช ืžื•ืฆืจื™ื ืžืชื•ืš ื’'ื™ื™ืกื•ืŸ ืœืงื˜ืœื•ื’ ืื•ืคื ื•ืขื™ื
86-
fetch('../assets/products.json')
98+
fetch(basePath + 'assets/products.json')
8799
.then(response => response.json())
88100
.then(products => {
89101
// ื‘ื“ื™ืงืช ื›ืžื•ืช ืžื•ืฆืจื™ื ื‘ืืชืจ

0 commit comments

Comments
ย (0)