abtmtr-v4/views/projects/scripts/data_get_projects.js
2024-02-29 00:25:03 -06:00

41 lines
1.3 KiB
JavaScript

const data_get = document.getElementById("data_get");
fetch_ask("./public/projects.json")
.then((x) => x.json())
.then((projects) => {
data_get.innerHTML = projects.items
.sort((a, b) => b.date - a.date)
.reduce(
(html, project) =>
html +
`<h1><a href="${project.url}">${project.name}${
/*<span style="vertical-align: middle;
font-size: 0.5em;">${project.tags.reduce(
(html, tag) =>
html +
`<button style="
--accent-color: ${projects.tags[tag]};
--accent-color-fg: #fff;
border-color: #fff;
margin: 0.25em;
">${tag}</button>`,
""
)}</span>*/ ""
}</a></h1>
<p><b>${new Date(project.date).toLocaleDateString()}</b></p>
${project.description.reduce(
(html, descfragment) => html + `<p>${descfragment}</p>`,
""
)}
${project.hotlink ? `` : `<p>
<button
onclick="window.manager.createWindow('${project.url}', false${
project.size?.[0] ? ", " + project.size[0] : ""
}${project.size?.[1] ? ", " + project.size[1] : ""})"
>
Open Window
</button>
</p>`}`,
""
);
});