-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtimeline.html
More file actions
executable file
·153 lines (132 loc) · 5.68 KB
/
timeline.html
File metadata and controls
executable file
·153 lines (132 loc) · 5.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
---
layout: default
---
<link rel="stylesheet" href="{{ site.baseurl }}/css/custom/timeline.css">
<div class="max-w-4xl mx-auto px-4 md:px-12 py-8 md:py-12">
{% assign default_lang = site.default_lang | default: 'ko' %}
{% assign timeline_posts_count = 0 %}
{% for post in site.posts %}
{% if post.lang == nil or post.lang == '' or post.lang == default_lang %}
{% assign timeline_posts_count = timeline_posts_count | plus: 1 %}
{% endif %}
{% endfor %}
<div class="timeline-header">
<h1>Timeline</h1>
<p>현재까지 {{ timeline_posts_count }}개의 글을 작성했어요.</p>
</div>
{% assign grouped_posts = site.posts | group_by_exp: "post", "post.date | date: '%Y'" %}
{% assign sorted_years = grouped_posts | sort: "name" | reverse %}
<div class="timeline-years-nav">
{% for year_group in sorted_years %}
{% assign visible_posts_count = 0 %}
{% for post in year_group.items %}
{% if post.lang == nil or post.lang == '' or post.lang == default_lang %}
{% assign visible_posts_count = visible_posts_count | plus: 1 %}
{% endif %}
{% endfor %}
{% if visible_posts_count > 0 %}
<a href="#timeline-year-{{ year_group.name }}" class="timeline-year-tag">
{{ year_group.name }}
<span class="timeline-year-tag-count">({{ visible_posts_count }})</span>
</a>
{% endif %}
{% endfor %}
</div>
<div class="timeline-container">
<div class="timeline-line"></div>
{% for year_group in sorted_years %}
{% assign visible_posts_count = 0 %}
{% for post in year_group.items %}
{% if post.lang == nil or post.lang == '' or post.lang == default_lang %}
{% assign visible_posts_count = visible_posts_count | plus: 1 %}
{% endif %}
{% endfor %}
{% if visible_posts_count > 0 %}
<div id="timeline-year-{{ year_group.name }}" class="timeline-year">
<div class="timeline-year-header">
<div class="timeline-year-dot"></div>
<span class="timeline-year-title">{{ year_group.name }}</span>
<span class="timeline-year-count">({{ visible_posts_count }})</span>
</div>
<div class="timeline-posts">
{% for post in year_group.items %}
{% if post.lang == nil or post.lang == '' or post.lang == default_lang %}
<div class="timeline-post">
<a href="{{ site.baseurl }}{{ post.url }}" class="timeline-post-link">
<div class="timeline-post-title">{{ post.title }}</div>
<time class="timeline-post-date">{{ post.date | date: "%Y년 %m월 %d일" }}</time>
</a>
</div>
{% endif %}
{% endfor %}
</div>
</div>
{% endif %}
{% endfor %}
<div class="timeline-milestone">
<div class="timeline-year-dot" style="background-color: rgb(34 197 94);"></div>
<div class="timeline-milestone-content">
<div class="timeline-milestone-title">GitHub 블로그로 이전</div>
<div class="timeline-milestone-date">2018년 1월 1일</div>
</div>
</div>
<div class="timeline-milestone">
<div class="timeline-year-dot" style="background-color: rgb(34 197 94);"></div>
<div class="timeline-milestone-content">
<div class="timeline-milestone-title">블로그 시작</div>
<div class="timeline-milestone-date">2014년 6월 18일부터</div>
</div>
</div>
</div>
</div>
<script>
document.querySelectorAll('.timeline-year-tag[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const targetId = this.getAttribute('href').substring(1);
const targetElement = document.getElementById(targetId);
if (!targetElement) return;
document.querySelectorAll('.timeline-year-tag').forEach(tag => {
tag.classList.remove('active');
});
this.classList.add('active');
const headerOffset = 80;
const elementPosition = targetElement.getBoundingClientRect().top;
const offsetPosition = elementPosition + window.pageYOffset - headerOffset;
window.scrollTo({
top: offsetPosition,
behavior: 'smooth'
});
});
});
function updateActiveTimelineYear() {
const years = document.querySelectorAll('.timeline-year[id]');
const tags = document.querySelectorAll('.timeline-year-tag[href^="#"]');
const headerOffset = 100;
let currentYear = '';
years.forEach(year => {
const yearTop = year.getBoundingClientRect().top;
const yearId = year.getAttribute('id');
if (yearTop <= headerOffset && yearTop >= -200) {
currentYear = yearId;
}
});
tags.forEach(tag => {
tag.classList.remove('active');
});
if (currentYear) {
const activeTag = document.querySelector(`.timeline-year-tag[href="#${currentYear}"]`);
if (activeTag) {
activeTag.classList.add('active');
}
}
}
let timelineScrollTimeout;
window.addEventListener('scroll', function () {
if (timelineScrollTimeout) {
clearTimeout(timelineScrollTimeout);
}
timelineScrollTimeout = setTimeout(updateActiveTimelineYear, 100);
});
updateActiveTimelineYear();
</script>