|
|
|
@ -1,35 +1,36 @@
|
|
|
|
|
import Fuse from 'fuse.js'
|
|
|
|
|
import $ from 'jquery'
|
|
|
|
|
|
|
|
|
|
function createTitleSearch() {
|
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
|
$.get('/links.json', function (documents) {
|
|
|
|
|
const options = {
|
|
|
|
|
keys: ['title'],
|
|
|
|
|
}
|
|
|
|
|
fetch('/links.json')
|
|
|
|
|
.then(result => result.json())
|
|
|
|
|
.then(documents => {
|
|
|
|
|
const options = {
|
|
|
|
|
keys: ['title'],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let commands = [
|
|
|
|
|
{title: 'Current Time', name: 'time'},
|
|
|
|
|
{title: 'Today', name: 'today'},
|
|
|
|
|
{title: 'Tomorrow', name: 'tomorrow'},
|
|
|
|
|
{title: 'Yesterday', name: 'yesterday'},
|
|
|
|
|
{title: 'TODO', name: 'todo'},
|
|
|
|
|
{title: 'DONE', name: 'done'},
|
|
|
|
|
{title: 'Page Reference', name: 'page_reference'},
|
|
|
|
|
{title: 'Code Block', name: 'code_block'},
|
|
|
|
|
];
|
|
|
|
|
let commands = [
|
|
|
|
|
{title: 'Current Time', name: 'time'},
|
|
|
|
|
{title: 'Today', name: 'today'},
|
|
|
|
|
{title: 'Tomorrow', name: 'tomorrow'},
|
|
|
|
|
{title: 'Yesterday', name: 'yesterday'},
|
|
|
|
|
{title: 'TODO', name: 'todo'},
|
|
|
|
|
{title: 'DONE', name: 'done'},
|
|
|
|
|
{title: 'Page Reference', name: 'page_reference'},
|
|
|
|
|
{title: 'Code Block', name: 'code_block'},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const fuseIndex = Fuse.createIndex(options.keys, documents)
|
|
|
|
|
let titleFuse = new Fuse(documents, options, fuseIndex)
|
|
|
|
|
let commandFuse = new Fuse(commands, {keys: ['title', 'name']})
|
|
|
|
|
const fuseIndex = Fuse.createIndex(options.keys, documents)
|
|
|
|
|
let titleFuse = new Fuse(documents, options, fuseIndex)
|
|
|
|
|
let commandFuse = new Fuse(commands, {keys: ['title', 'name']})
|
|
|
|
|
|
|
|
|
|
resolve({
|
|
|
|
|
documents,
|
|
|
|
|
titleSearch: titleFuse,
|
|
|
|
|
commandSearch: commandFuse,
|
|
|
|
|
commands: commands,
|
|
|
|
|
resolve({
|
|
|
|
|
documents,
|
|
|
|
|
titleSearch: titleFuse,
|
|
|
|
|
commandSearch: commandFuse,
|
|
|
|
|
commands: commands,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|