Skip to content

Commit a73fb45

Browse files
authored
Merge pull request #36 from HomeofNever/phase2/embeds-comments
2 parents 6e45f1e + 18566bf commit a73fb45

11 files changed

Lines changed: 74 additions & 28 deletions

eleventy.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ export default function (eleventyConfig) {
2525

2626
eleventyConfig.setLibrary("md", md);
2727

28+
// --- Shortcodes ---
29+
eleventyConfig.addShortcode("youtube", (id) => {
30+
return `<div class="aspect-video my-4"><iframe src="https://www.youtube-nocookie.com/embed/${id}" title="YouTube video" frameborder="0" loading="lazy" referrerpolicy="strict-origin-when-cross-origin" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen class="w-full h-full"></iframe></div>`;
31+
});
32+
33+
eleventyConfig.addShortcode("tweet", (id, conversation) => {
34+
const convoAttr = conversation === "none" ? ' data-conversation="none"' : "";
35+
return `<blockquote class="twitter-tweet"${convoAttr}><a href="https://twitter.com/i/status/${id}">Tweet</a></blockquote>`;
36+
});
37+
38+
eleventyConfig.addShortcode("telegram", (channel, msgid) => {
39+
return `<script async src="https://telegram.org/js/telegram-widget.js?22" data-telegram-post="${channel}/${msgid}" data-width="100%"></script>`;
40+
});
41+
2842
// --- Passthrough copy ---
2943
eleventyConfig.addPassthroughCopy("src/assets");
3044
eleventyConfig.addPassthroughCopy("src/static");

src/_includes/layouts/base.njk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@
1515
{{ content | safe }}
1616
</main>
1717
{% include "footer.njk" %}
18+
{% if "twitter-tweet" in content %}
19+
<script async src="https://platform.twitter.com/widgets.js"></script>
20+
{% endif %}
1821
</body>
1922
</html>

src/_includes/layouts/post.njk

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,24 @@ layout: layouts/base.njk
3131
<div class="prose prose-lg max-w-none">
3232
{{ content | safe }}
3333
</div>
34+
35+
<hr class="my-12">
36+
37+
<section class="giscus-comments" aria-label="评论">
38+
<script src="https://giscus.app/client.js"
39+
data-repo="homeofnever/blog"
40+
data-repo-id="MDEwOlJlcG9zaXRvcnkxNTI2NjcxNzQ="
41+
data-category="Comments"
42+
data-category-id="DIC_kwDOCRmEJs4C51bD"
43+
data-mapping="pathname"
44+
data-strict="0"
45+
data-reactions-enabled="1"
46+
data-emit-metadata="0"
47+
data-input-position="top"
48+
data-theme="light"
49+
data-lang="zh-CN"
50+
crossorigin="anonymous"
51+
async>
52+
</script>
53+
</section>
3454
</article>

src/pages/about.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ permalink: /about/
1717

1818
设定图做出来了
1919

20-
<!-- TODO: Tweet embed, Phase 2 -->
20+
{% tweet "1162786240371937280" %}
2121

2222

2323
### 2018.12.03

src/posts/2020-red-pack-writeup.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ date: 2021-01-01 20:00:01
1212

1313
## 剧情前提
1414

15-
<!-- TODO: embed migration Phase 2 -->
15+
{% telegram "liyuans", "36350" %}
1616

1717

1818
在Leonn的博客频道看到这个, https://blog.berd.moe/archives/2020-review/
@@ -134,11 +134,9 @@ decrypt(h)
134134

135135
🆒
136136

137-
{% raw %}
138137
<pre>
139-
{{ cool_file }}
138+
🆕6️⃣🍿🍔🌭🥪🌮🍆🥑💬🍔💬🌭💬🥪💬🌮💬🍆💬🥑🛑🆕🔟🤔🖇🙃🍖🍟🥔🌽🥩🥕🌶️🌯🥥❓🆓⚖️🆓✖️🆓➗🙃🔢1️⃣8️⃣4️⃣7️⃣🔢🛑4️⃣🛑🔢2️⃣4️⃣8️⃣🔢🛑🆓🍿🌶️🥥🌽🥕🌽🥔🍿🌽🍖🌽🥩🌯🍟🛑🆓💬🔤🚫📥️🔛🔤🛑🛑💬🔤💻🔑🔑🔑🔑🔑🔑🔤🤔🎛️🔤9️⃣❤️9️⃣4️⃣🔤🔤1️⃣9️⃣7️⃣4️⃣🔤🔤4️⃣💜💛7️⃣🔤🔤➖🔤🔤🧡7️⃣9️⃣9️⃣🔤🔤8️⃣❤️4️⃣💛🔤🔤💚6️⃣0️⃣💛🔤🔤2️⃣5️⃣💙1️⃣🔤🔤2️⃣3️⃣7️⃣2️⃣🔤
140139
</pre>
141-
{% endraw %}
142140

143141
首先我得说, 这个题目对Linux有点不友好, [🆒](https://gitlab.com/fogity/squared-cool) 是一个只能用emoji写的语言, Linux的emoji支持...
144142

src/posts/2020-summary.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description: 「さようなら」
99
date: 2021-01-04 10:00:00
1010
---
1111

12-
<!-- TODO: embed migration Phase 2 -->
12+
{% youtube "RQsM2uvXow8" %}
1313

1414
> ^背景音乐
1515
@@ -25,7 +25,7 @@ date: 2021-01-04 10:00:00
2525

2626
#### 毛装做出来了
2727

28-
<!-- TODO: embed migration Phase 2 -->
28+
{% tweet "1218216503138451457" %}
2929

3030
从国内运过来运费花了差不多1000RMB, 算是我在爱好上开销比较大的一次了
3131

@@ -143,9 +143,9 @@ date: 2021-01-04 10:00:00
143143
- 锁了 Instagram, 关闭大部分 Google 账户数据收集
144144

145145

146-
#### 转向了 FastMail
146+
#### 转向了 FastMail
147147

148-
<!-- TODO: embed migration Phase 2 -->
148+
{% tweet "1303101728921968641" %}
149149

150150
在某个时间点开始, 我开始有意远离谷歌类的产品了, 第一件事就是把自己的邮箱彻底从谷歌搬走.
151151

@@ -161,7 +161,7 @@ date: 2021-01-04 10:00:00
161161

162162
#### 邮箱被人爆破了
163163

164-
<!-- TODO: embed migration Phase 2 -->
164+
{% tweet "1286042436494655488" %}
165165

166166
自己开了一个免费的邮箱托管服务, 结果自己设置了个弱密码, 没什么好说的
167167

@@ -177,7 +177,7 @@ date: 2021-01-04 10:00:00
177177

178178
#### 入了 3D 打印的坑
179179

180-
<!-- TODO: embed migration Phase 2 -->
180+
{% tweet "1297718215003471874" %}
181181

182182
搬家, 100刀从别人手里拿下了一台 Ender 3, 一通改装效果不错. 刷了 Klipper, 升级了 BLTouch
183183

@@ -204,9 +204,9 @@ date: 2021-01-04 10:00:00
204204

205205
不过好的是铁头给我的这个三手`86U`我出出去的时候居然还多了200RMB, ~~真的保值~~
206206

207-
#### 拿到了ASN!
207+
#### 拿到了ASN!
208208

209-
<!-- TODO: embed migration Phase 2 -->
209+
{% tweet "1335886440874586113" %}
210210

211211
https://bgp.he.net/AS212243
212212

@@ -255,8 +255,7 @@ Honda CR-V 2021, 到落地差不多32k刀
255255

256256
我倒不是说不想上, 家里给钱上学? 上学诶, 这可算是很轻松的活了好吧, 要是以前的我估计说不出这话, 但是看过这么多事情过来, 上学在其中可能算真的简单的了. 但是在研究生里要做什么确实得要好好想想了, 不能再过得浑浑噩噩的了
257257

258-
<!-- TODO: embed migration Phase 2 -->
259-
258+
{% youtube "MBRqu0YOH14" %}
260259

261260
> 在最后放上这个小视频结尾: 成就和错误终将回归烟云, 散落四周.
262261
> 有起有落才是人生; 少年啊, 真正的愁苦是说不出来的.

src/posts/keep-your-google-voice-with-sao.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,23 @@ Tasker 是我当时为了挂国内短信卡而购入的一款自动化软件,
7474

7575
自动回复指令: `/sao`, 不要多也不要少哦
7676

77-
{% raw %}
78-
`(`{{ front }}`)`{{ middle }}`-`{{ end }}
79-
80-
<!-- TODO: interactive widget, Phase 2 -->
81-
{% endraw %}
77+
<code>(<span id="gv-front">258</span>) <span id="gv-middle">1776</span>-<span id="gv-end">10000</span></code>
78+
79+
<button id="gv-recal" style="padding: 4px 12px; cursor: pointer;">计算</button>
80+
81+
<script>
82+
(function() {
83+
var front = 258, middle = 1776, end = 10000;
84+
document.getElementById('gv-recal').addEventListener('click', function() {
85+
front -= 17;
86+
middle /= 2;
87+
end -= 160;
88+
document.getElementById('gv-front').textContent = front;
89+
document.getElementById('gv-middle').textContent = middle;
90+
document.getElementById('gv-end').textContent = end;
91+
});
92+
})();
93+
</script>
8294

8395
就酱~
8496

src/posts/my-lovely-hard-drives.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ description: Seagate Expansion, WD mybook, Elements, 12tb, 10tb, 8tb, 我都买
4646

4747
![10tb 174USD, 8tb 145USD](/assets/media/my-lovely-hard-drives/newegg_1.png)
4848

49-
<!-- TODO: embed migration Phase 2 -->
49+
{% tweet "1254180643682095105" %}
5050

5151
虽然很多人说希捷的盘不是很好, 到时候反正也要组个 raid, 我自己之前的希捷盘也用了 8000 个小时, 感觉问题不大
5252

@@ -83,8 +83,8 @@ description: Seagate Expansion, WD mybook, Elements, 12tb, 10tb, 8tb, 我都买
8383
希捷的盘不掉速, WD 会有波动
8484
虽然说 https://post.smzdm.com/p/aoo6m4l6/ 这篇评测说不是 SMR, 但是掉速这个很奇怪
8585

86-
<!-- TODO: embed migration Phase 2 -->
87-
<!-- TODO: embed migration Phase 2 -->
86+
{% tweet "1254287135106117632", "none" %}
87+
{% tweet "1254699445100384256", "none" %}
8888

8989
测速原图, USB:
9090

@@ -154,7 +154,7 @@ description: Seagate Expansion, WD mybook, Elements, 12tb, 10tb, 8tb, 我都买
154154

155155
#### 开箱
156156

157-
<!-- TODO: embed migration Phase 2 -->
157+
{% tweet "1258465154670436353", "none" %}
158158
![](/assets/media/my-lovely-hard-drives/easystore_10tb_openbox.jpg)
159159

160160
####

src/posts/nano-pi-neo2-first-experience.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Zerotier 黑箱子实在不好debug...
5757

5858
淘宝店铺最低的是99,当我看上了准备买的时候,发现商家是广州的,一问是不是在岗顶的新赛格,还真的是,于是直接上门买了,省下10块钱邮费,嘻嘻
5959

60-
<!-- TODO: embed migration Phase 2 -->
60+
{% telegram "ButNothingHappened", "2956" %}
6161

6262
## 跑!
6363

@@ -81,7 +81,7 @@ NanoPI的卡槽是有弹簧的,这个比树莓派体验好上不少
8181

8282
### 开机
8383

84-
<!-- TODO: embed migration Phase 2 -->
84+
{% telegram "ButNothingHappened", "2958" %}
8585

8686
(见上图)开机直接飙到46度,是有点小难受,早知道就配上散热片了,开久了亚克力板还是有点烫的。因为是监控机要求长时间开着,这个算是有点失策。
8787

src/posts/space-and-s-p-a-c-e.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ _注:本文不会过多描述编码,直接切入话题。如果不了解相
5353
str.split('').join(' ')
5454
```
5555

56-
<!-- TODO: embed migration Phase 2 -->
56+
{% telegram "ButNothingHappened", "3010" %}
5757

5858
这个问题是啥呢?我们来看看[MDN - Split](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split#Syntax)的文档:
5959

0 commit comments

Comments
 (0)