diff --git a/data/config.json b/data/config.json index 19459f8..81aec5c 100644 --- a/data/config.json +++ b/data/config.json @@ -14,5 +14,8 @@ "url": "https://github.com/patarapolw/zhdiary" } ], - "fullUrl": "https://zhdiary.polvcode.dev" + "fullUrl": "https://zhdiary.polvcode.dev", + "author": { + "name": "Pacharapol Withayasakpunt" + } } \ No newline at end of file diff --git a/data/posts/千字文/千字文1.2.md b/data/posts/千字文/千字文1.2.md index 4e6c4c9..202f179 100644 --- a/data/posts/千字文/千字文1.2.md +++ b/data/posts/千字文/千字文1.2.md @@ -37,13 +37,7 @@ tag: figcaption.text-center zhang1 ``` - - ```css parsed -table td:first-child { - width: 10em; -} - figure { width: 100px; } @@ -55,6 +49,14 @@ figure { } ``` + + +```css parsed +table td:first-child { + width: 10em; +} +``` + 盈利 | yínglì | profit / gain 轻盈 | qīngyíng | graceful / lithe / light and graceful / lighthearted / relaxed 盈亏 | yíngkuī | profit and loss / waxing and waning diff --git a/data/posts/千字文/千字文1.4.md b/data/posts/千字文/千字文1.4.md index 1ba3229..b500acc 100644 --- a/data/posts/千字文/千字文1.4.md +++ b/data/posts/千字文/千字文1.4.md @@ -37,13 +37,7 @@ tag: figcaption.text-center yang2 ``` - - ```css parsed -table td:first-child { - width: 10em; -} - figure { width: 100px; } @@ -55,6 +49,14 @@ figure { } ``` + + +```css parsed +table td:first-child { + width: 10em; +} +``` + 闰年 | rùnnián | leap year / (lunar calendar) year with a thirteen intercalary month 闰月 | rùnyuè | intercalary month in the lunar calendar / leap month 敖闰 | Áorùn | Dragon King of the West Sea, Ao Run, also Ao Ji (敖吉) diff --git a/data/posts/千字文/千字文1.6.md b/data/posts/千字文/千字文1.6.md index fdabfdc..03d3c14 100644 --- a/data/posts/千字文/千字文1.6.md +++ b/data/posts/千字文/千字文1.6.md @@ -37,13 +37,7 @@ tag: figcaption.text-center gang1 ``` - - ```css parsed -table td:first-child { - width: 10em; -} - figure { width: 100px; } @@ -55,6 +49,14 @@ figure { } ``` + + +```css parsed +table td:first-child { + width: 10em; +} +``` + 资金 | zījīn | funds / funding / capital 基金 | jījīn | fund 黄金 (黃金) | huángjīn | gold / golden (opportunity) / prime (time) diff --git a/data/posts/千字文/千字文1.7.md b/data/posts/千字文/千字文1.7.md index f68b9fc..11896d0 100644 --- a/data/posts/千字文/千字文1.7.md +++ b/data/posts/千字文/千字文1.7.md @@ -37,13 +37,7 @@ tag: figcaption.text-center guang1 ``` - - ```css parsed -table td:first-child { - width: 10em; -} - figure { width: 100px; } @@ -55,6 +49,14 @@ figure { } ``` + + +```css parsed +table td:first-child { + width: 10em; +} +``` + 刀剑 (刀劍) | dāojiàn | sword 剑桥 (劍橋) | Jiànqiáo | Cambridge 利剑 (利劍) | lìjiàn | sharp sword diff --git a/data/posts/千字文/千字文1.8.md b/data/posts/千字文/千字文1.8.md index ea1ac6c..b86353d 100644 --- a/data/posts/千字文/千字文1.8.md +++ b/data/posts/千字文/千字文1.8.md @@ -37,13 +37,7 @@ tag: figcaption.text-center jiang1 ``` - - ```css parsed -table td:first-child { - width: 10em; -} - figure { width: 100px; } @@ -55,6 +49,14 @@ figure { } ``` + + +```css parsed +table td:first-child { + width: 10em; +} +``` + 如果 | rúguǒ | if / in case / in the event that 结果 (結果) | jiēguǒ | to bear fruit / CL: 個|个 结果 (結果) | jiéguǒ | outcome / result / conclusion / in the end / as a result / to kill / to dispatch diff --git a/data/posts/千字文/千字文1.9.md b/data/posts/千字文/千字文1.9.md index 811b5e0..a06ffc4 100644 --- a/data/posts/千字文/千字文1.9.md +++ b/data/posts/千字文/千字文1.9.md @@ -37,13 +37,7 @@ tag: figcaption.text-center xiang2 ``` - - ```css parsed -table td:first-child { - width: 10em; -} - figure { width: 100px; } @@ -55,6 +49,14 @@ figure { } ``` + + +```css parsed +table td:first-child { + width: 10em; +} +``` + 海报 (海報) | hǎibào | poster / playbill / notice 海外 | hǎiwài | overseas / abroad 海洋 | hǎiyáng | ocean / CL: 個|个 diff --git a/data/posts/千字文/千字文2.3.md b/data/posts/千字文/千字文2.3.md index 02c9118..8daa99d 100644 --- a/data/posts/千字文/千字文2.3.md +++ b/data/posts/千字文/千字文2.3.md @@ -37,13 +37,7 @@ tag: figcaption.text-center tang2 ``` - - ```css parsed -table td:first-child { - width: 10em; -} - figure { width: 100px; } @@ -55,6 +49,14 @@ figure { } ``` + + +```css parsed +table td:first-child { + width: 10em; +} +``` + 推荐 (推薦) | tuījiàn | to recommend / recommendation 推广 (推廣) | tuīguǎng | to extend / to spread / to popularize / generalization / promotion (of a product etc) 推动 (推動) | tuīdòng | to push (for acceptance of a plan) / to push forward / to promote / to actuate / CL: 個|个 diff --git a/data/posts/千字文/千字文2.7.md b/data/posts/千字文/千字文2.7.md index c67d8ed..446a128 100644 --- a/data/posts/千字文/千字文2.7.md +++ b/data/posts/千字文/千字文2.7.md @@ -37,13 +37,7 @@ tag: figcaption.text-center wang2 ``` - - ```css parsed -table td:first-child { - width: 10em; -} - figure { width: 100px; } @@ -55,6 +49,14 @@ figure { } ``` + + +```css parsed +table td:first-child { + width: 10em; +} +``` + 遐想 | xiáxiǎng | reverie / daydream / to be lost in wild and fanciful thoughts 闻名遐迩 (聞名遐邇) | wénmíngxiá'ěr | to be famous far and wide (idiom) 遐 | xiá | distant / long-lasting / to abandon diff --git a/data/posts/千字文/千字文2.8.md b/data/posts/千字文/千字文2.8.md index 04128c6..d88591e 100644 --- a/data/posts/千字文/千字文2.8.md +++ b/data/posts/千字文/千字文2.8.md @@ -37,13 +37,7 @@ tag: figcaption.text-center chang2 ``` - - ```css parsed -table td:first-child { - width: 10em; -} - figure { width: 100px; } @@ -55,6 +49,14 @@ figure { } ``` + + +```css parsed +table td:first-child { + width: 10em; +} +``` + 鸣 (鳴) | míng | to cry (of birds, animals and insects) 共鸣 (共鳴) | gòngmíng | resonance (physics) / sympathetic response to sth 争鸣 (爭鳴) | zhēngmíng | to contend diff --git a/data/posts/千字文/千字文3.2.md b/data/posts/千字文/千字文3.2.md index 99dd361..367c7ce 100644 --- a/data/posts/千字文/千字文3.2.md +++ b/data/posts/千字文/千字文3.2.md @@ -37,13 +37,7 @@ tag: figcaption.text-center shang1 ``` - - ```css parsed -table td:first-child { - width: 10em; -} - figure { width: 100px; } @@ -55,6 +49,14 @@ figure { } ``` + + +```css parsed +table td:first-child { + width: 10em; +} +``` + 恭喜 | gōngxǐ | congratulations / greetings 恭 | gōng | respectful 恭贺 (恭賀) | gōnghè | to congratulate respectfully / to express good wishes diff --git a/data/posts/千字文/千字文3.3.md b/data/posts/千字文/千字文3.3.md index 36cffcb..5f1dfef 100644 --- a/data/posts/千字文/千字文3.3.md +++ b/data/posts/千字文/千字文3.3.md @@ -37,13 +37,7 @@ tag: figcaption.text-center liang2 ``` - - ```css parsed -table td:first-child { - width: 10em; -} - figure { width: 100px; } @@ -55,6 +49,14 @@ figure { } ``` + + +```css parsed +table td:first-child { + width: 10em; +} +``` + 女性 | nǚxìng | woman / the female sex 女子 | nǚzǐ | woman / female 女孩 | nǚhái | girl / lass diff --git a/web/backend/package.json b/web/backend/package.json index 35a2c4d..f765af4 100644 --- a/web/backend/package.json +++ b/web/backend/package.json @@ -10,6 +10,7 @@ "dependencies": { "@patarapolw/qsearch": "^1.1.1", "cors": "^2.8.5", + "dayjs": "^1.8.21", "express": "^4.17.1", "fast-glob": "^3.2.2", "gray-matter": "^4.0.2", diff --git a/web/backend/scripts/prepare.ts b/web/backend/scripts/prepare.ts index 40f79bb..3008344 100644 --- a/web/backend/scripts/prepare.ts +++ b/web/backend/scripts/prepare.ts @@ -4,6 +4,7 @@ import crypto from 'crypto' import matter from 'gray-matter' import glob from 'fast-glob' import DataStore from 'nedb-promises' +import dayjs from 'dayjs' import MakeHtml from '../src/utils/make-html' @@ -44,6 +45,7 @@ const db = new DataStore('assets/data.nedb') await db.insert({ ...data, + date: formatDate(data.date), filename: f, h, excerpt: computedExcerpt, @@ -64,8 +66,13 @@ const db = new DataStore('assets/data.nedb') computedContent = computedContent.substr(computedExcerpt.length) } + if (data.date) { + console.log(formatDate(data.date)) + } + await db.insert({ ...data, + date: formatDate(data.date), filename: f, h, excerpt: computedExcerpt, @@ -77,3 +84,17 @@ const db = new DataStore('assets/data.nedb') } })) })().catch(console.error) + +const tzOffset = new Date().getTimezoneOffset() + +function formatDate (d?: string | Date) { + if (d) { + if (typeof d === 'string') { + return dayjs(d).toDate() + } else { + return dayjs(d).add(tzOffset, 'minute').toDate() + } + } + + return d +} diff --git a/web/backend/src/api/data.ts b/web/backend/src/api/data.ts index 8045499..a221e34 100644 --- a/web/backend/src/api/data.ts +++ b/web/backend/src/api/data.ts @@ -26,26 +26,29 @@ dataRouter.get('/*', (req, res) => { dataRouter.post('/', async (req, res, next) => { try { - const { q, project, offset, limit } = req.body - let cond = q - if (typeof q === 'string') { + const { q, cond = {}, project, offset, limit } = req.body + const $and = [ + { filename: { $regex: /^posts\// } }, + cond + ] as any[] + + if (q) { const parser = new QSearch({ dialect: 'nedb', schema: { + title: {}, filename: {}, excerpt: {}, date: { type: 'date' } } }) - cond = parser.parse(q) + $and.push(parser.parse(q)) } - const count = await db.count(cond) + const count = await db.count({ $and }) + + let c = db.find({ $and }, project).skip(offset || 0) - let c = db.find(cond).skip(offset || 0) - if (project) { - c = c.projection(project) - } if (limit !== null) { c = c.limit(limit || 5) } diff --git a/web/backend/yarn.lock b/web/backend/yarn.lock index 2f1145c..e037543 100644 --- a/web/backend/yarn.lock +++ b/web/backend/yarn.lock @@ -420,6 +420,11 @@ dateformat@~1.0.4-1.2.3: get-stdin "^4.0.1" meow "^3.3.0" +dayjs@^1.8.21: + version "1.8.21" + resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.8.21.tgz#98299185b72b9b679f31c7ed987b63923c961552" + integrity sha512-1kbWK0hziklUHkGgiKr7xm59KwAg/K3Tp7H/8X+f58DnNCwY3pKYjOCJpIlVs125FRBukGVZdKZojC073D0IeQ== + debounce@^1.0.0: version "1.2.0" resolved "https://registry.yarnpkg.com/debounce/-/debounce-1.2.0.tgz#44a540abc0ea9943018dc0eaa95cce87f65cd131" diff --git a/web/frontend/package.json b/web/frontend/package.json index eb882bc..1724761 100644 --- a/web/frontend/package.json +++ b/web/frontend/package.json @@ -10,6 +10,7 @@ "axios": "^0.19.2", "buefy": "^0.8.12", "core-js": "^3.6.4", + "dayjs": "^1.8.21", "vue": "^2.6.11", "vue-class-component": "^7.2.2", "vue-extend-layout": "^2.0.6", diff --git a/web/frontend/public/index.html b/web/frontend/public/index.html index 3e91c3f..39bdf80 100644 --- a/web/frontend/public/index.html +++ b/web/frontend/public/index.html @@ -5,6 +5,7 @@ +
- For a guide and recipes on how to configure / customize this project,
- check out the
- vue-cli documentation.
-
-