Skip to content

Commit 02a59e8

Browse files
committed
announcements panel added
1 parent 663e063 commit 02a59e8

File tree

7 files changed

+66
-4
lines changed

7 files changed

+66
-4
lines changed

_data/announcements.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"content": "🚀 Video eğitime indirimli katılmak için tıklayın.",
4+
"link": "https://www.udemy.com/course/kali-linux-ile-sifirdan-temel-linux-egitimi/?couponCode=7F64F329A3F847685A94",
5+
"start_date": "2023-12-28",
6+
"end_date": "2024-01-02",
7+
"limited": true
8+
9+
},
10+
]

_includes/announcement.html

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{% for announcement in site.data.announcements %}
2+
{% assign current_date = site.time | date: "%Y-%m-%d" %}
3+
{% assign start_date = announcement.start_date %}
4+
{% assign end_date = announcement.end_date %}
5+
6+
{% if current_date >= start_date and current_date <= end_date %}
7+
{% if announcement.limited %}
8+
<p class="yesil text-center text-success">{{ announcement.content }} <br> <a id="countdown_{{ forloop.index }}"></a>
9+
<a href="{{ announcement.link }}" class="stretched-link"></a>
10+
</p>
11+
12+
<script>
13+
// İndirim bitiş tarihi (YYYY-MM-DD HH:mm:ss)
14+
var countDownDate{{ forloop.index }} = new Date("{{ announcement.end_date }}").getTime();
15+
16+
// Her bir saniyede bir geri sayımı güncelle
17+
var x{{ forloop.index }} = setInterval(function() {
18+
19+
// Şu anki tarih ve saat
20+
var now = new Date().getTime();
21+
22+
// Geri sayım için kalan zaman
23+
var distance = countDownDate{{ forloop.index }} - now;
24+
25+
// Gün, saat, dakika ve saniye hesaplamaları
26+
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
27+
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
28+
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
29+
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
30+
31+
// Günü kontrol et
32+
var dayText = days > 1 ? days + " gün " : "";
33+
34+
// HTML içeriğini güncelle
35+
document.getElementById("countdown_{{ forloop.index }}").innerHTML = "<strong>Kalan süre:</strong> " +
36+
dayText + hours + " saat " + minutes + " dakika " + seconds + " saniye kaldı.";
37+
38+
// Eğer geri sayım tamamlandıysa
39+
if (distance < 0) {
40+
clearInterval(x{{ forloop.index }});
41+
document.getElementById("countdown_{{ forloop.index }}").innerHTML = "<strong>İndirim Sona Erdi!</strong>";
42+
}
43+
}, 1000);
44+
</script>
45+
{% else %}
46+
<p class="yesil text-center text-success">{{ announcement.content }}
47+
<a href="{{ announcement.link }}" class="stretched-link"></a>
48+
</p>
49+
{% endif %}
50+
{% endif %}
51+
{% endfor %}

_layouts/b-post.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<body data-pagefind-body>
77

88
{% include nav-page.html %}
9-
9+
{% include announcement.html %}
1010

1111

1212
<div class="container-fluid">

_layouts/komut.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<body data-pagefind-body>
77

88
{% include nav-page.html %}
9-
9+
{% include announcement.html %}
1010

1111

1212
<div class="container-fluid">

_layouts/post.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</head>
66
<body>
77
{% include nav-page.html %}
8-
8+
{% include announcement.html %}
99
<div class="container">
1010
{% include meta-data.html %}
1111
{{ content }}

_layouts/simple.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<body data-pagefind-ignore="all">
77

88
{% include nav-page.html %}
9-
9+
{% include announcement.html %}
1010
<div class="container">
1111
<p></p>
1212
{{ content }}

_layouts/tutorial.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<div id="progress-bar-container">
1717
<div id="progress-bar"></div>
1818
</div>
19+
{% include announcement.html %}
1920
<div class="container-fluid">
2021
<div class="row mb-2">
2122
<div style="font-size: 18px;" class="col-md-9" data-pagefind-filter="Bölüm:Eğitim Serisi:">

0 commit comments

Comments
 (0)