add query page
This commit is contained in:
1 parent
c2ae07be06
commit
3bc2a943bd
31 files changed
+380
-164
No files matched your search
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user