-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
98 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
document.addEventListener("DOMContentLoaded", function () { | ||
// Function to fetch JSON data from a file | ||
function fetchJSONFile(path, callback) { | ||
var xhr = new XMLHttpRequest(); | ||
xhr.onreadystatechange = function () { | ||
if (xhr.readyState === XMLHttpRequest.DONE) { | ||
if (xhr.status === 200) { | ||
var data = JSON.parse(xhr.responseText); | ||
if (callback) { | ||
callback(data); | ||
} | ||
} else { | ||
console.error("Failed to fetch JSON data"); | ||
} | ||
} | ||
}; | ||
xhr.open("GET", path, true); | ||
xhr.send(); | ||
} | ||
|
||
// Call the fetchJSONFile function to load data from the JSON file | ||
fetchJSONFile("/scripts/blogposts.json", function (jsonData) { | ||
// Sort data by published date (assuming the date is in a consistent format) | ||
jsonData.sort(function (a, b) { | ||
return new Date(b.published_date) - new Date(a.published_date); | ||
}); | ||
|
||
// Get the card container | ||
var cardContainer = document.getElementById("cardContainer"); | ||
|
||
// Loop through JSON data and generate HTML for each item | ||
jsonData.forEach(function (item) { | ||
// Replace placeholders in description with actual HTML anchor tags | ||
var description = item.description.replace( | ||
"[here]", | ||
'<a class="icon-link" href="' + item.link + '">here <i class="bi bi-box-arrow-up-right"></i></a>' | ||
); | ||
description = description.replace( | ||
"[Read more]", | ||
'<a class="icon-link" href="' + item.link + '">Read more <i class="bi bi-box-arrow-up-right"></i></a>' | ||
); | ||
|
||
var cardHtml = ` | ||
<div class="col"> | ||
<div class="card h-100"> | ||
<img src="${item.image_src}" class="card-img-top" alt="..." /> | ||
<div class="card-body"> | ||
<h5 class="card-title">${item.title}</h5> | ||
<p class="card-text">${description}</p> | ||
</div> | ||
<div class="card-footer"> | ||
<small class="text-body-secondary">Published on ${item.published_date}</small> | ||
</div> | ||
</div> | ||
</div> | ||
`; | ||
cardContainer.innerHTML += cardHtml; | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[ | ||
{ | ||
"title": "New Kits got announced!", | ||
"image_src": "/static/images/blog/rivieraretreatcozybistro.png", | ||
"description": "The Riviera Retreat Kit & the Cozy Bistro Kit just got announced. The Riviera Retreat Kit is a pool themed Kit with new pool fountains, pool trims, stucco, archways and more! <br /> <br /> The Cozy Bistro Kit is a bistro themed Kit with new tables, chairs, awnings wallpapers and more! <br /> <br /> They will both be available May 30, 2024 on all usual platforms. You can find more about these in the EA blog post [here].", | ||
"link": "https://www.ea.com/games/the-sims/the-sims-4/news/cozy-bistro-and-riviera-retreat-kits", | ||
"published_date": "May 28, 2024" | ||
}, | ||
{ | ||
"title": "The Blooming Rooms Kit is FREE!", | ||
"image_src": "/static/images/cover/The_Sims_4_Blooming_Rooms_Cover.jpg", | ||
"description": "You can get the Blooming Rooms Kit for free now and then have it forever. Click [here] to be taken to the official EA Website to redeem it for free! <br /> <br /> Disclaimer: This offer is exclusively accessible through the EA App on Mac and PC until June 17th.", | ||
"link": "https://www.ea.com/games/the-sims/the-sims-4/store/addons/the-sims-4-blooming-rooms-kit", | ||
"published_date": "May 25, 2024" | ||
}, | ||
{ | ||
"title": "New Kit: \"Party Essentials\"", | ||
"image_src": "/static/images/cover/The_Sims_4_Party_Essentials_Cover.jpg", | ||
"description": "The Sims announced two new kits! This one - the Party Essentials Kit has party props like baloons, a fog machine, speakers, a disco ball and more! Both of the Kits are scheduled to be released April 18th, 2024 at 10AM Pacific Time. They will cost 4,99 USD / 4,99 EUR each. You can get it [here].", | ||
"link": "https://www.ea.com/games/the-sims/the-sims-4/store/addons/the-sims-4-party-essentials-kit", | ||
"published_date": "April 10, 2024" | ||
}, | ||
{ | ||
"title": "New Kit: \"Urban Homage\"", | ||
"image_src": "/static/images/cover/The_Sims_4_Urban_Homage_Cover.jpg", | ||
"description": "The Sims announced two new kits! This one - the Urban Homage Kit was created in collaboration with Danielle \"Ebonix\" Udogaranya. It has London-city 90s and 2000s inspired clothing with lively patterns, vibrant graffiti motifs and eye-catching accessories. Both of the Kits are scheduled to be released April 18th, 2024 at 10AM Pacific Time. They will cost 4,99 USD / 4,99 EUR each. You can get it [here].", | ||
"link": "https://www.ea.com/games/the-sims/the-sims-4/store/addons/the-sims-4-urban-homage-kit", | ||
"published_date": "April 10, 2024" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes