File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 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+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments