Skip to content

Instantly share code, notes, and snippets.

Avatar

Sam Dutton samdutton

View GitHub Profile
@samdutton
samdutton / sample.vtt
Created Feb 2, 2018
Sample WebVTT caption file
View sample.vtt
WEBVTT
00:00:00.500 --> 00:00:02.000
The Web is always changing
00:00:02.500 --> 00:00:04.300
and the way we access it is changing
@samdutton
samdutton / index.json
Last active Feb 2, 2018
Lunr search index
View index.json
{
"index": {
"title": {
"root": {
"9": {
"8": {
"docs": {
"98+Short+Sleeve+Tee": {
"tf": 1
},
@samdutton
samdutton / main.js
Created Feb 2, 2018
Search with Elasticlunr
View main.js
const matches = index.search(‘foo’);
@samdutton
samdutton / main.js
Created Feb 2, 2018
Get Elasticlunr index file
View main.js
// main.js running on the user's browser
fetch('data/index.json').then(response => {
return response.json();
}).then(json => {
index = elasticlunr.Index.load(json);
});
@samdutton
samdutton / index.js
Created Feb 2, 2018
Create Elasticlunr search index
View index.js
// node index.js
// get documents to be indexed.
const docs = getDocs();
const index = elasticlunr(function() {
// Set fields to index.
this.addField('name');
this.addField('description');
// Set the field used to identify documents.
this.setRef('id');
@samdutton
samdutton / index.json
Last active Feb 1, 2018
Lunr index snippet
View index.json
{
"index": {
"title": {
"root": {
"9": {
"8": {
"docs": {
"98+Short+Sleeve+Tee": {
"tf": 1
},