From cc517b7333279cdedf92ad907c0829f68ea58b84 Mon Sep 17 00:00:00 2001 From: patarapolw Date: Mon, 12 Aug 2019 22:28:58 +0700 Subject: [PATCH] create first post --- config.yaml | 2 +- package-lock.json | 6 +- plugins/cogear-plugin-blog | 2 +- src/app.scss | 0 src/app.ts | 25 ++++++++ src/{app.js => disqus.js} | 0 src/pages/index.md | 2 +- src/pages/p/2019/08/12-千字文1.md | 14 ----- src/pages/p/2019/08/千字文1.pug | 76 +++++++++++++++++++++++++ themes/blog/layouts/includes/mixins.pug | 4 +- themes/blog/layouts/sidebar.pug | 2 + 11 files changed, 112 insertions(+), 21 deletions(-) create mode 100644 src/app.scss create mode 100644 src/app.ts rename src/{app.js => disqus.js} (100%) delete mode 100644 src/pages/p/2019/08/12-千字文1.md create mode 100644 src/pages/p/2019/08/千字文1.pug diff --git a/config.yaml b/config.yaml index 96b48b0..6b1543b 100644 --- a/config.yaml +++ b/config.yaml @@ -11,7 +11,7 @@ blog: split: === title: "中文 Diary" pages: - ^p/: + ^/?p/: layout: post author: login: polvcode diff --git a/package-lock.json b/package-lock.json index 91dd3ce..75aa173 100644 --- a/package-lock.json +++ b/package-lock.json @@ -173,9 +173,9 @@ "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==" }, "acorn": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.2.1.tgz", - "integrity": "sha512-JD0xT5FCRDNyjDda3Lrg/IxFscp9q4tiYtxE1/nOzlKCk7hIRuYjhq1kCNkbPjMRMZuFq20HNQn1I9k8Oj0E+Q==" + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.3.0.tgz", + "integrity": "sha512-/czfa8BwS88b9gWQVhc8eknunSA2DoJpJyTQkhheIf5E48u1N0R4q/YxxsAeqRrmK9TQ/uYfgLDfZo91UlANIA==" }, "ajv": { "version": "6.10.2", diff --git a/plugins/cogear-plugin-blog b/plugins/cogear-plugin-blog index 424da42..8991587 160000 --- a/plugins/cogear-plugin-blog +++ b/plugins/cogear-plugin-blog @@ -1 +1 @@ -Subproject commit 424da42bbe3bcdb7d2462b60b3d5ff248fcb84eb +Subproject commit 8991587e58e57aa504ee147a59fb16a26dc7a271 diff --git a/src/app.scss b/src/app.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app.ts b/src/app.ts new file mode 100644 index 0000000..a646a25 --- /dev/null +++ b/src/app.ts @@ -0,0 +1,25 @@ +import "./disqus"; + +window.addEventListener("keydown", (ev) => { + if (ev.key === "s") { + const s = window.getSelection().toString(); + if (s) { + speak(s); + } + } +}) + +function speak(s: string) { + const allVoices = speechSynthesis.getVoices(); + let vs = allVoices.filter((v) => /zh[-_]cn/i.test(v.lang)); + if (vs.length === 0) { + vs = allVoices.filter((v) => /zh/i.test(v.lang)); + } + + if (vs.length > 0) { + const u = new SpeechSynthesisUtterance(s); + u.lang = vs[0].lang; + u.rate = 0.8; + speechSynthesis.speak(u); + } +} diff --git a/src/app.js b/src/disqus.js similarity index 100% rename from src/app.js rename to src/disqus.js diff --git a/src/pages/index.md b/src/pages/index.md index be011cf..9719988 100644 --- a/src/pages/index.md +++ b/src/pages/index.md @@ -1,3 +1,3 @@ --- -title: 'Cogear.JS – modern st' +title: '中文 Diary - My Chinese learning diary' --- \ No newline at end of file diff --git a/src/pages/p/2019/08/12-千字文1.md b/src/pages/p/2019/08/12-千字文1.md deleted file mode 100644 index cb3b7f3..0000000 --- a/src/pages/p/2019/08/12-千字文1.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: "千字文(qian2 zi3 wen2)- 1" -date: "2019-08-12" -tags: - - 千字文 - - 汉字 ---- - -# 天地玄黃,宇宙洪荒。 - -![](https://upload.wikimedia.org/wikipedia/commons/a/ab/天-order.gif) -![](https://upload.wikimedia.org/wikipedia/commons/f/fb/地-order.gif) -![](https://upload.wikimedia.org/wikipedia/commons/d/d3/玄-order.gif) -![](https://upload.wikimedia.org/wikipedia/commons/e/e7/黄-order.gif) diff --git a/src/pages/p/2019/08/千字文1.pug b/src/pages/p/2019/08/千字文1.pug new file mode 100644 index 0000000..66f6bdb --- /dev/null +++ b/src/pages/p/2019/08/千字文1.pug @@ -0,0 +1,76 @@ +--- +title: "千字文 (qian2 zi3 wen2) - 1" +date: "2019-08-11" +tags: + - 千字文 + - 汉字 +--- + +.w-100.mt-3: h3.text-center 天地玄黃,宇宙洪荒。 +.w-100 + figure.d-inline-block + img(src="https://upload.wikimedia.org/wikipedia/commons/a/ab/天-order.gif" height=100) + figcaption.text-center tian1 + figure.d-inline-block + img(src="https://upload.wikimedia.org/wikipedia/commons/f/fb/地-order.gif" height=100) + figcaption.text-center di4 + figure.d-inline-block + img(src="https://upload.wikimedia.org/wikipedia/commons/d/d3/玄-order.gif" height=100) + figcaption.text-center xuan2 + figure.d-inline-block + img(src="https://upload.wikimedia.org/wikipedia/commons/e/e7/黄-order.gif" height=100) + figcaption.text-center huang2 +.w-100 + figure.d-inline-block + img(src="https://www.mdbg.net/chinese/rsc/img/stroke_anim/23431.gif" height=100) + figcaption.text-center yu3 + figure.d-inline-block + img(src="https://www.mdbg.net/chinese/rsc/img/stroke_anim/23449.gif" height=100) + figcaption.text-center zhou4 + figure.d-inline-block + img(src="https://www.mdbg.net/chinese/rsc/img/stroke_anim/27946.gif" height=100) + figcaption.text-center hong2 + figure.d-inline-block + img(src="https://www.mdbg.net/chinese/rsc/img/stroke_anim/33618.gif" height=100) + figcaption.text-center huang1 + +| === + +.w-100.mt-3 + table.table + colgroup + col(style="width: 6em") + col + col + tr + td 宇宙 + td yǔzhòu + td universe / cosmos + tr + td 宇航 + td yǔháng + td space flight + tr + td 宇航员 + td yǔhángyuán + td astronaut + tr + td 宇宙飞船 + td yǔzhòufēichuán + td spacecraft + tr + td 防洪 + td fánghóng + td flood control / flood prevention + tr + td 山洪 + td shānhóng + td mountain flash flood / mountain torrent + tr + td 荒 + td huāng + td desolate / shortage / scarce / out of practice / absurd / uncultivated / to neglect + tr + td 荒野 + td huāngyě + td wilderness diff --git a/themes/blog/layouts/includes/mixins.pug b/themes/blog/layouts/includes/mixins.pug index 4ec8842..5bf1b0d 100644 --- a/themes/blog/layouts/includes/mixins.pug +++ b/themes/blog/layouts/includes/mixins.pug @@ -13,7 +13,9 @@ mixin post(post) h1= post.title .post-content!= post.teaser ? post.teaser : post.content if !post.teaser - a(href="javascript: history.back()") ← Back + ul.mt-3.pagination + li.page-item + a.page-link(href="javascript: history.back()") ← Back mixin date(date) - let months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'] - let d = new Date(date) diff --git a/themes/blog/layouts/sidebar.pug b/themes/blog/layouts/sidebar.pug index 73121cb..f9ecc20 100644 --- a/themes/blog/layouts/sidebar.pug +++ b/themes/blog/layouts/sidebar.pug @@ -3,5 +3,7 @@ aside.card.p-3 :markdown-it #### Record my journey to Chinese by [@polvcode](https://polvcode.dev) + Highlight text and press "s" to speak. + a.twitter-timeline(href="https://twitter.com/ChinesePol" data-height="600") Tweets by ChinesePol script(async src="https://platform.twitter.com/widgets.js" charset="utf-8") \ No newline at end of file