Repository navigation
Expand file tree
/
Copy pathload.js
More file actions
256 lines (205 loc) · 7.58 KB
/
Copy pathload.js
File metadata and controls
256 lines (205 loc) · 7.58 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
const allBlogs = [
{
"cover": "./assets/09_15_2025_The_One_Skill_Every_STEM_Major_Needs.jpg",
"published": "September 15, 2025",
"summary": "This one skill is the most important, but most neglected, skill for STEM majors.",
"tags": ["Communication", "Skills", "STEM"],
"title": "The One Skill Every STEM Major Needs — But No One Teaches",
"url": "https://jo2eph.github.io/blog/posts/2025/09_15_communication_skill/",
},
{
"cover": "./assets/09_18_2025_Reflection_on_UChicago_Craft_of_Writing_Effectively.png",
"published": "September 18, 2025",
"summary": "A reflection on The Craft of Writing Effectively by the University of Chicago.",
"tags": ["Writing", "UChicago", "Reflection"],
"title": "A Reflection on UChicago's \"Craft of Writing Effectively\"",
"url": "https://jo2eph.github.io/blog/posts/2025/09_18_reflection_on_uchicago_writing/",
},
{
"cover": "./assets/09_22_2025_Cybersecurity_for_Everyone.png",
"published": "September 22, 2025",
"summary": "Cybersecurity is for everyone. Simple tips and habits to stay safe online.",
"tags": ["Cybersecurity", "Cryptography", "Online Safety"],
"title": "Cybersecurity for Everyone: Protect Yourself Online Without Being a Tech Expert",
"url": "https://jo2eph.github.io/blog/posts/2025/09_22_cybersecurity_for_everyone",
}
];
// Create Blog Card
function createBlogCard(cover, published, summary, tags, title, url) {
// Initialize blog card div element
const blogCard = document.createElement("div");
blogCard.classList.add("blog-card");
// Blog Image
blogCard.appendChild(createBlogImage(cover, title, url));
// Blog Title
blogCard.appendChild(createBlogTitle(title, url));
// Blog Description Container
blogCard.appendChild(createBlogDescriptionContainer(published, summary, tags));
return blogCard;
}
/* BLOG IMAGE:
<div class="blog-image">
<a href="(URL) title="(TITLE)">
<img src="(COVER)" alt="(TITLE)" title="(TITLE)">
</a>
</div>
*/
function createBlogImage(cover, title, url) {
const blogImage = document.createElement("div");
blogImage.classList.add("blog-image");
const blogImageChild = document.createElement("a");
blogImageChild.setAttribute("href", url);
blogImageChild.setAttribute("title", title);
const blogImageChildCover = document.createElement("img");
blogImageChildCover.setAttribute("src", cover);
blogImageChildCover.setAttribute("alt", title);
blogImageChildCover.setAttribute("title", title);
blogImageChild.appendChild(blogImageChildCover);
blogImage.appendChild(blogImageChild);
return blogImage;
}
/* BLOG TITLE:
<div class="blog-title">
<h2>
<a href="(URL)" title="(TITLE)">
(TITLE)
</a>
</h2>
</div>
*/
function createBlogTitle(title, url) {
const blogTitle = document.createElement("div");
blogTitle.classList.add("blog-title");
const blogTitleHeader = document.createElement("h2");
const blogTitleHeaderChild = document.createElement("a");
blogTitleHeaderChild.setAttribute("href", url);
blogTitleHeaderChild.setAttribute("title", title);
blogTitleHeaderChild.textContent = title;
blogTitleHeader.appendChild(blogTitleHeaderChild);
blogTitle.appendChild(blogTitleHeader);
return blogTitle;
}
/* BLOG DESCRIPTION CONTAINER
CONTAINS 3 DIV CHILDREN NODES:
<div class="blog-description-container">
<div class="blog-summary">
(SUMMARY)
</div>
<div class="blog-author-container">
<div class="blog-author">
<img src="./assets/photo.jpg" alt="Joseph Lee" title="Joseph Lee">
</div>
<div class="blog-publish-container">
<div class="blog-author-name">
Joseph Lee
</div>
<div class="blog-publish-date">
(PUBLISHED)
</div>
</div>
</div>
<div class="blog-tags"> (TAGS)
<span class="tag">
TAG
</span>
</div>
</div>
*/
function createBlogDescriptionContainer(published, summary, tags) {
const blogDescriptionContainer = document.createElement("div");
blogDescriptionContainer.classList.add("blog-description-container");
// Blog Summary
blogDescriptionContainer.appendChild(createBlogSummary(summary));
// Blog Author Container
blogDescriptionContainer.appendChild(createBlogAuthorContainer(published));
// Blog Tags
blogDescriptionContainer.appendChild(createBlogTags(tags));
return blogDescriptionContainer;
}
/* BLOG SUMMARY:
<div class="blog-summary">
(SUMMARY)
</div>
*/
function createBlogSummary(summary) {
const blogSummary = document.createElement("div");
blogSummary.classList.add("blog-summary");
blogSummary.textContent = summary;
return blogSummary;
}
/* BLOG AUTHOR CONTAINER:
<div class="blog-author-container">
<div class="blog-author">
<img src="./assets/photo.jpg" alt="Joseph Lee" title="Joseph Lee">
</div>
<div class="blog-publish-container">
<div class="blog-author-name">
Joseph Lee
</div>
<div class="blog-publish-date">
(PUBLISHED)
</div>
</div>
</div>
*/
function createBlogAuthorContainer(published) {
const blogAuthorContainer = document.createElement("div");
blogAuthorContainer.classList.add("blog-author-container");
// Blog Author
const blogAuthor = document.createElement("div");
blogAuthor.classList.add("blog-author");
const blogAuthorImage = document.createElement("img");
blogAuthorImage.setAttribute("src", "./assets/photo.jpg");
blogAuthorImage.setAttribute("alt", "Joseph Lee");
blogAuthorImage.setAttribute("title", "Joseph Lee");
blogAuthor.appendChild(blogAuthorImage);
blogAuthorContainer.appendChild(blogAuthor);
// Blog Publish Container
const blogPublishContainer = document.createElement("div");
blogPublishContainer.classList.add("blog-publish-container");
// Blog Author Name
const blogAuthorName = document.createElement("div");
blogAuthorName.classList.add("blog-author-name");
blogAuthorName.textContent = "Joseph Lee";
blogPublishContainer.appendChild(blogAuthorName);
// Blog Publish Date
const blogPublishDate = document.createElement("div");
blogPublishDate.classList.add("blog-publish-date");
blogPublishDate.textContent = published;
blogPublishContainer.appendChild(blogPublishDate);
blogAuthorContainer.appendChild(blogPublishContainer);
return blogAuthorContainer;
}
/* BLOG TAGS:
<div class="blog-tags"> (TAGS)
<span class="tag">
TAG
</span>
</div>
*/
function createBlogTags(tags) {
const blogTags = document.createElement("div");
blogTags.classList.add("blog-tags");
tags.forEach(tag => {
const blogTag = document.createElement("span");
blogTag.classList.add("tag");
blogTag.textContent = tag;
blogTags.appendChild(blogTag);
})
return blogTags;
}
// Load Blog Cards
const blogCardsContainer = document.getElementById("blog-cards-container");
window.addEventListener('load', () => {
// Load each blog cards into home page
allBlogs.forEach(blog => {
let cover = blog["cover"];
let published = blog["published"];
let summary = blog["summary"];
let tags = blog["tags"];
let title = blog["title"];
let url = blog["url"];
const blogCard = createBlogCard(cover, published, summary, tags, title, url);
blogCardsContainer.appendChild(blogCard);
});
});