Problem: we don't support natural language dates in page search
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Solution: add natural language date parser and allow to create new pages
This commit is contained in:
parent
3c53e14229
commit
d7d205f502
13
editor/package-lock.json
generated
13
editor/package-lock.json
generated
|
@ -1895,6 +1895,14 @@
|
|||
"integrity": "sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==",
|
||||
"dev": true
|
||||
},
|
||||
"chrono-node": {
|
||||
"version": "2.3.5",
|
||||
"resolved": "https://registry.npmjs.org/chrono-node/-/chrono-node-2.3.5.tgz",
|
||||
"integrity": "sha512-QIWEgXYVn55/Nsgdqbe6inqW+GoK3B6Qtga8AWdpq+nd+mOZVMxa+SGwPq/XjY+nKN+toQGu8KifCPwUkmz2sg==",
|
||||
"requires": {
|
||||
"dayjs": "^1.10.0"
|
||||
}
|
||||
},
|
||||
"class-utils": {
|
||||
"version": "0.3.6",
|
||||
"resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz",
|
||||
|
@ -2655,6 +2663,11 @@
|
|||
"assert-plus": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"dayjs": {
|
||||
"version": "1.10.7",
|
||||
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.7.tgz",
|
||||
"integrity": "sha512-P6twpd70BcPK34K26uJ1KT3wlhpuOAPoMwJzpsIWUxHZ7wpmbdZL/hQqBDfz7hGurYSa5PhzdhDHtt319hL3ig=="
|
||||
},
|
||||
"debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
"@egjs/hammerjs": "^2.0.17",
|
||||
"axios": "^0.19.2",
|
||||
"bulma": "^0.7.5",
|
||||
"chrono-node": "^2.3.5",
|
||||
"clipboard": "^2.0.8",
|
||||
"copy-text-to-clipboard": "^2.2.0",
|
||||
"css-loader": "^3.6.0",
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import $ from 'jquery'
|
||||
import qs from 'querystring';
|
||||
import qs from 'querystring'
|
||||
import * as chrono from 'chrono-node'
|
||||
import moment from 'moment';
|
||||
|
||||
function search(element) {
|
||||
return {
|
||||
|
@ -26,6 +28,16 @@ function startQuery(query) {
|
|||
line: 'New page',
|
||||
text: 'New page',
|
||||
})
|
||||
let parseResult = chrono.nl.casual.parse(query)
|
||||
if (parseResult.length) {
|
||||
let m = moment(parseResult[0].start.date())
|
||||
actualResult.push({
|
||||
ref: m.format('LL').replace(/\s+/g, '_'),
|
||||
title: m.format('LL'),
|
||||
line: 'Suggested page',
|
||||
text: 'Suggested page'
|
||||
})
|
||||
}
|
||||
$.each(data.hits, (key, value) => {
|
||||
actualResult.push({
|
||||
ref: value.fields.page,
|
||||
|
|
Loading…
Reference in New Issue
Block a user