Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
d2e7a17c7a | |||
f6062d30cb |
|
@ -3,7 +3,7 @@ const syntaxHighlightingPlugin = require("@11ty/eleventy-plugin-syntaxhighlight"
|
|||
const markdownIt = require('markdown-it');
|
||||
const markdownItClass = require('@toycode/markdown-it-class');
|
||||
const markdownItAnchor = require('markdown-it-anchor')
|
||||
|
||||
const searchFilter = require("./content/filters/searchFilter");
|
||||
|
||||
module.exports = function(eleventyConfig) {
|
||||
eleventyConfig.addPlugin(navigationPlugin)
|
||||
|
@ -12,6 +12,8 @@ module.exports = function(eleventyConfig) {
|
|||
eleventyConfig.addPassthroughCopy("assets")
|
||||
eleventyConfig.addPassthroughCopy("fonts")
|
||||
|
||||
eleventyConfig.addFilter("search", searchFilter);
|
||||
|
||||
eleventyConfig.addShortcode("fas_icon", function(name) { return `<span class="fas fa-${name}"></span>` })
|
||||
|
||||
const mapping = {
|
||||
|
|
10
assets/js/elasticlunr.min.js
vendored
Normal file
10
assets/js/elasticlunr.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
19
content/filters/searchFilter.js
Normal file
19
content/filters/searchFilter.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
const elasticlunr = require("elasticlunr");
|
||||
|
||||
module.exports = function (collection) {
|
||||
var index = elasticlunr(function () {
|
||||
this.setRef("id");
|
||||
this.addField("title");
|
||||
this.addField("content");
|
||||
});
|
||||
|
||||
collection.forEach((page) => {
|
||||
index.addDoc({
|
||||
id: page.url,
|
||||
title: page.title,
|
||||
content: page.content,
|
||||
});
|
||||
});
|
||||
|
||||
return index.toJSON();
|
||||
};
|
6
content/search-index.njk
Normal file
6
content/search-index.njk
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
permalink: /search-index.json
|
||||
layout: null
|
||||
---
|
||||
|
||||
{{ collections.all | search | dump | safe }}
|
13
package-lock.json
generated
13
package-lock.json
generated
|
@ -10,6 +10,7 @@
|
|||
"@11ty/eleventy-navigation": "^0.3.2",
|
||||
"@11ty/eleventy-plugin-syntaxhighlight": "^3.1.2",
|
||||
"@toycode/markdown-it-class": "^1.2.4",
|
||||
"elasticlunr": "^0.9.5",
|
||||
"markdown-it-anchor": "^8.1.2"
|
||||
}
|
||||
},
|
||||
|
@ -1073,6 +1074,12 @@
|
|||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/elasticlunr": {
|
||||
"version": "0.9.5",
|
||||
"resolved": "https://registry.npmjs.org/elasticlunr/-/elasticlunr-0.9.5.tgz",
|
||||
"integrity": "sha1-ZVQbswnd3Qz5Ty0ciGGyvmUbsNU=",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/emoji-regex": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||
|
@ -4880,6 +4887,12 @@
|
|||
"integrity": "sha512-7vmuyh5+kuUyJKePhQfRQBhXV5Ce+RnaeeQArKu1EAMpL3WbgMt5WG6uQZpEVvYSSsxMXRKOewtDk9RaTKXRlA==",
|
||||
"dev": true
|
||||
},
|
||||
"elasticlunr": {
|
||||
"version": "0.9.5",
|
||||
"resolved": "https://registry.npmjs.org/elasticlunr/-/elasticlunr-0.9.5.tgz",
|
||||
"integrity": "sha1-ZVQbswnd3Qz5Ty0ciGGyvmUbsNU=",
|
||||
"dev": true
|
||||
},
|
||||
"emoji-regex": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"@11ty/eleventy-navigation": "^0.3.2",
|
||||
"@11ty/eleventy-plugin-syntaxhighlight": "^3.1.2" ,
|
||||
"@toycode/markdown-it-class": "^1.2.4",
|
||||
"markdown-it-anchor": "^8.1.2"
|
||||
"markdown-it-anchor": "^8.1.2",
|
||||
"elasticlunr": "^0.9.5"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue