Skip to content

Commit

Permalink
Public only and lazy image loading
Browse files Browse the repository at this point in the history
  • Loading branch information
valleballe committed Oct 14, 2024
1 parent 3f86323 commit 3c5a862
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ document.addEventListener('DOMContentLoaded', () => {
let startYear = new Date(project.start_on).getFullYear();
if (startYear < 1985){
startYear = new Date(project.created).getFullYear();
project.start_on = project.created;
}
return isNaN(startYear) ? null : startYear;
}).filter(year => year !== null))];
Expand Down Expand Up @@ -64,8 +65,9 @@ document.addEventListener('DOMContentLoaded', () => {
projectGrid.innerHTML = '';
projects.forEach(project => {
const startYear = new Date(project.start_on).getFullYear();
const visibility = project.visibility;

if (startYear === year) {
if (startYear === year && visibility=="PUBLIC") {
const projectContainer = document.createElement('div');
projectContainer.classList.add('project-container');
const imgURL = project.hero_image_url;
Expand All @@ -74,6 +76,7 @@ document.addEventListener('DOMContentLoaded', () => {
const img = document.createElement('img');
img.src = imgURL;
img.alt = project.title;
img.loading="lazy";
projectContainer.appendChild(img);
} else {
const grayValue = Math.floor(Math.random() * 256);
Expand Down

0 comments on commit 3c5a862

Please sign in to comment.