-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.html
105 lines (85 loc) · 3.7 KB
/
index.html
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
---
title: Home
---
<div class="home">
<ul class="community ul-reset text-center">
<li class="community__item">
<a class="community__link" href="https://github.com/f2etw/f2etw.github.io">
<span class="community__cover" style="background-position: 25% 50%, 80% 50%; background-size: contain, 35%; background-image: url('https://avatars2.githubusercontent.com/u/8252114'), url('https://assets-cdn.github.com/images/modules/logos_page/GitHub-Logo.png');">
<span class="community__name">f2etw.github.io @ GitHub</span>
</span>
<span class="community__desc">這是本網站的 Github,若你對這個網站有任何意見、想法,我們隨時歡迎你的貢獻 & PR!</span>
</a>
</li>
</ul>
<br>
{% if site.posts != empty %}
<ul class="activity ul-reset" style="max-width: 70%">
{% for post in site.posts %}
<li class="activity-item">
<a class="activity-link" href="{{ post.url}}">
<time class="activity-time">{{ post.date | date: "%Y-%m-%d" }}</time>
{{ post.title }}
</a>
</li>
{% endfor %}
</ul>
{% endif %}
<h2 class="text-center"><img src="/images/facebook.svg" alt="facebook icon"> Front-End Developers Taiwan 社群動態</h2>
<ul class="community ul-reset text-center">
<li class="community__item">
<a class="community__link" href="https://www.facebook.com/groups/f2e.tw">
<span class="community__cover" style="background-position: 50% 0; background-image: url('https://scontent.xx.fbcdn.net/hphotos-xpt1/t31.0-8/s720x720/11891894_886287831419653_2265712281735358894_o.jpg');">
<span class="community__name">Front-End Developers Taiwan</span>
</span>
<span class="community__desc">這是 F2ETW 的 facebook 社團,歡迎加入社群!可以在這徵才、詢問問題,讓前端在臺灣更加成熟!</span>
</a>
</li>
</ul>
<ul class="posts ul-reset"></ul>
<script>
fetch('https://graph.facebook.com/521085554595481/feed?access_token=1385521591772831|lMcuWxJls6aEK-IwR0Z-_AQVMV4').then(function(response) {
return response.json();
})
.then(function(posts) {
console.log(posts,0);
var content = [];
var msg;
var removeUnsafeChar = function (str) {
str = str.toString();
return str.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
};
posts.data.map(function(post, index, array) {
post.name = post.name || '';
post.from.name = post.from.name || '';
var _html = '';
if (post.message) {
msg = post.message || '';
msg = removeUnsafeChar(post.message);
_html += `
<li class="post">
<a href="https://facebook.com/${post.from.id}"><img src="https://graph.facebook.com/${post.from.id}/picture?width=60&height=60" title="${post.from.name}" alt="${post.from.name}" class="post__avatar" /></a>
<div class="post__content">`
if(msg) {
_html += `<a class="post__msg" href="https://facebook.com/${post.id}">${msg}</a>`
}
if(post.link && post.picture) {
_html += `<div class="post__preview"><a class="post__preview__link" href="${post.link}" class="link"><img class="post__preview__img" src="${post.picture}" alt=""/>${post.name}</a></div>`
}
_html += `</div></li>`;
}
content.push(_html);
});
return content;
})
.catch(function(err) {
return "<p>請點選上方社團連結以觀看社團貼文!</p>";
}).then(function (content) {
document.querySelector('.posts').innerHTML = content.join('');
});
</script>
</div>