This commit is contained in:
parent
45075f88dd
commit
01362715b9
@ -9,6 +9,10 @@ const loadSection = (sectionName) =>{
|
|||||||
.catch(error => console.error('Error loading JSON:', error));
|
.catch(error => console.error('Error loading JSON:', error));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cap(str) {
|
||||||
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||||
|
}
|
||||||
|
|
||||||
// Recursive function to handle strings, arrays, and objects
|
// Recursive function to handle strings, arrays, and objects
|
||||||
const renderItems = (items) => {
|
const renderItems = (items) => {
|
||||||
return items.map(item => {
|
return items.map(item => {
|
||||||
@ -18,8 +22,8 @@ const renderItems = (items) => {
|
|||||||
return renderItems(item); // recurse into nested array
|
return renderItems(item); // recurse into nested array
|
||||||
} else if (typeof item === 'object') {
|
} else if (typeof item === 'object') {
|
||||||
return `<p>${Object.entries(item).map(([key, value]) =>
|
return `<p>${Object.entries(item).map(([key, value]) =>
|
||||||
`${value}`).join('<br>')}</p>`;
|
// `${value}`).join('<br>')}</p>`;
|
||||||
// `<strong>${key}:</strong> ${value}`).join('<br>')}</p>`;
|
`<strong>${cap(key)}:</strong> ${value}`).join('<br>')}</p>`;
|
||||||
} else {
|
} else {
|
||||||
return `<p>${String(item)}</p>`;
|
return `<p>${String(item)}</p>`;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user