Skip to content

Commit 3f26b09

Browse files
committed
Added leftover js
1 parent 32d051b commit 3f26b09

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

docs/_static/daily-recipe.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
(function() {
2+
// Calculate days since Unix epoch (January 1, 1970)
3+
var millisecondsPerDay = 1000 * 60 * 60 * 24;
4+
var today = new Date();
5+
var utcMidnight = Date.UTC(today.getFullYear(), today.getMonth(), today.getDate());
6+
var epoch = Date.UTC(1970, 0, 1);
7+
var daysSinceEpoch = Math.floor((utcMidnight - epoch) / millisecondsPerDay);
8+
9+
// Calculate index based on the day of the year
10+
var index = daysSinceEpoch % examplesData.length;
11+
12+
// Get the example
13+
var example = examplesData[index];
14+
15+
// Build the HTML code
16+
var html = '';
17+
html += '<div class="grid">';
18+
html += ' <div class="grid-item">';
19+
html += ' <div class="card" style="text-align: center; box-shadow: md;">';
20+
html += ' <a href="' + example.ref + '" class="doc">';
21+
html += ' <h3 class="card-title">' + example.title + '</h3>';
22+
html += ' <img src="' + example.thumbnail + '" alt="' + example.description + '" class="gallery-img">';
23+
html += ' </a>';
24+
html += ' <p>' + example.description + "</p>";
25+
html += ' </div>';
26+
html += ' </div>';
27+
html += '</div>';
28+
29+
// Insert the HTML into the page
30+
var container = document.getElementById('daily-thumbnail');
31+
if (container) {
32+
container.innerHTML = html;
33+
}
34+
})();

0 commit comments

Comments
 (0)