Skip to content

Commit

Permalink
Made the blog post into json
Browse files Browse the repository at this point in the history
  • Loading branch information
jespermhl committed May 28, 2024
1 parent 9cc95da commit 895ad6d
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 139 deletions.
137 changes: 3 additions & 134 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<meta name="robots" content="index,follow" />

<script src="/scripts/meta.js"></script>
<script src="/scripts/blog.js"></script>
</head>
<body>
<div class="wrapper">
Expand All @@ -52,140 +53,8 @@ <h1 style="padding-top: 3em">Sul Sul, Simmers!</h1>
browsing!
</p>
<h2>News</h2>
<div class="row row-cols-1 row-cols-md-3 g-4">
<div class="col">
<div class="card h-100">
<img
src="/static/images/blog/rivieraretreatcozybistro.png"
class="card-img-top"
alt="..." />
<div class="card-body">
<h5 class="card-title">New Kits got announced!</h5>
<p class="card-text">
The Riviera Retreat Kit & the Cozy Bistro Kit just
got announced. The Reviera 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
<a
class="icon-link"
href="https://www.ea.com/games/the-sims/the-sims-4/news/cozy-bistro-and-riviera-retreat-kits">
here
<i class="bi bi-box-arrow-up-right"></i></a
>.
</p>
</div>
<div class="card-footer">
<small class="text-body-secondary">
Published on May 28, 2024
</small>
</div>
</div>
</div>
<div class="col">
<div class="card h-100">
<img
src="/static/images/cover/The_Sims_4_Blooming_Rooms_Cover.jpg"
class="card-img-top"
alt="..." />
<div class="card-body">
<h5 class="card-title">
The Blooming Rooms Kit is FREE!
</h5>
<p class="card-text">
You can get the Blooming Rooms Kit for free now
and then have it forever. Click
<a
class="icon-link"
href="https://www.ea.com/games/the-sims/the-sims-4/store/addons/the-sims-4-blooming-rooms-kit">
here <i class="bi bi-box-arrow-up-right"></i>
</a>
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.
</p>
</div>
<div class="card-footer">
<small class="text-body-secondary">
Published on May 20, 2024
</small>
</div>
</div>
</div>
<div class="col">
<div class="card h-100">
<img
src="/static/images/cover/The_Sims_4_Party_Essentials_Cover.jpeg"
class="card-img-top"
alt="Party Essentials Cover" />
<div class="card-body">
<h5 class="card-title">
New Kit: "Party Essentials"
</h5>
<p class="card-text">
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.
</p>
<a
href="https://www.ea.com/games/the-sims/the-sims-4/store/addons/the-sims-4-party-essentials-kit"
class="btn btn-primary">
Buy on EA.com
<i class="bi bi-box-arrow-up-right"></i>
</a>
</div>
<div class="card-footer">
<small class="text-body-secondary">
Date of publishing unknown</small
>
</div>
</div>
</div>
<div class="col">
<div class="card h-100">
<img
src="/static/images/cover/The_Sims_4_Urban_Homage_Cover.jpg"
class="card-img-top"
alt="Urban Homage Cover" />
<div class="card-body">
<h5 class="card-title">New Kit: "Urban Homage"</h5>
<p class="card-text">
The Sims announced two new kits! This one - the
Urban Homage Kit was created in collaboration with
Danielle &quot;Ebonix&quot; 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.
</p>
<a
href="https://www.ea.com/games/the-sims/the-sims-4/store/addons/the-sims-4-urban-homage-kit"
class="btn btn-primary">
Buy on EA.com
<i class="bi bi-box-arrow-up-right"></i>
</a>
</div>
<div class="card-footer">
<small class="text-body-secondary"
>Date of publishing unknown</small
>
</div>
</div>
</div>
<div id="cardContainer" class="row row-cols-1 row-cols-md-3 g-4">
<!-- Blog posts will be added here -->
</div>
</div>
</main>
Expand Down
60 changes: 60 additions & 0 deletions scripts/blog.js
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;
});
});
});
30 changes: 30 additions & 0 deletions scripts/blogposts.json
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"
}
]
10 changes: 5 additions & 5 deletions scripts/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,18 @@ for (let i = 0; i < 3; i++) {
async: ""
});

addElementToHead("script", {
src: "/scripts/posthog.js",
/*addElementToHead("script", {
src: "/scripts/blog.js",
async: ""
});
});*/

addElementToHead("script", {
async: "",
defer: "",
src: "https://beampipe.io/js/tracker.js",
"data-beampipe-domain": "https://beampipe.io/js/tracker.js"
});

// addElementToHead("script", {
// name: "defer",
// "data-domain": "simsinfohub.com",
Expand Down

0 comments on commit 895ad6d

Please sign in to comment.