11"use strict" ;
2- // const projectsItems = document.querySelector(".projects-items ");
3- const projectsItems = document . getElementById ( "projects-items" ) ;
2+ const list = document . querySelector ( ".projects-list " ) ;
3+ // const projectsItems = document.getElementById("projects-items");
44const canvas = document . getElementById ( "pradip-canvas" ) ,
55 context = canvas . getContext ( "2d" ) ;
66const ancherEl = document . querySelectorAll ( "a" ) ;
@@ -10,63 +10,29 @@ window.onload = function () {
1010 console . log ( "Loaded" ) ;
1111} ;
1212
13- fetch ( "./api .json" )
13+ fetch ( "./projects .json" )
1414 . then ( ( res ) => res . json ( ) )
1515 . then ( ( data ) => updateUI ( data ) ) ;
1616
1717// UpdateUI
18- // const updateUI = (projects) => {
19- // projects.map(({ name, code, index }) => {
20- // const itemList = document.createElement("li");
21- // itemList.innerHTML = `
22- // <span class="project-number">${index}</span>
23- // <span class="project-name">
24- // <a href="/${index}-${name}/index.html" target="_blank" >
25- // ${projectNameFormatter(name)}
26- // </a>
27- // </span>
28- // <a href="${code}" target="_blank" class="code-link">
29- // ${"{"} code ${"}" }
30- // </a>
31- // `;
32- // list.appendChild(itemList);
33- // });
34- // };
35-
3618const updateUI = ( projects ) => {
37- projects . map (
38- ( {
39- id,
40- name,
41- category,
42- features,
43- problem_solve,
44- description,
45- tag,
46- language,
47- cover_img,
48- code_link,
49- } ) => {
50- const projectItem = document . createElement ( "div" ) ;
51- projectItem . className = "project-item" ;
52- console . log ( projectItem ) ;
53- projectItem . innerHTML = `
54- <img src="./assets/screen/thumbnail.png" alt="" />
55- <div class="project-info">
56- <div class="lang">${ language } </div>
57- <a href=${ code_link } >
58- <h3 class="project-name">${ name } </h3>
59- </a>
60- <p class="description">
61- ${ description }
62- </p>
63-
64- </div>
65- ` ;
66- projectsItems . appendChild ( projectItem ) ;
67- }
68- ) ;
19+ projects . map ( ( { name, code, index } ) => {
20+ const itemList = document . createElement ( "li" ) ;
21+ itemList . innerHTML = `
22+ <span class="project-number">${ index } </span>
23+ <span class="project-name">
24+ <a href="/${ index } -${ name } /index.html" target="_blank" >
25+ ${ projectNameFormatter ( name ) }
26+ </a>
27+ </span>
28+ <a href="${ code } " target="_blank" class="code-link">
29+ ${ "{" } code ${ "}" }
30+ </a>
31+ ` ;
32+ list . appendChild ( itemList ) ;
33+ } ) ;
6934} ;
35+
7036// Project Name Formatter
7137const projectNameFormatter = ( name ) => {
7238 return name
0 commit comments