diff --git a/docs/search-index.11ty.js b/docs/search-index.11ty.js new file mode 100644 index 0000000..ebc5c71 --- /dev/null +++ b/docs/search-index.11ty.js @@ -0,0 +1,29 @@ +module.exports = +class SearchIndex { + constructor() {} + data() { + // Export Front Matter + return { + permalink: "/search-index.jsonl", + eleventyExcludeFromCollections: true + }; + } + render(data) { + let str = ""; + + for (const pageIdx in data.collections.all) { + const page = data.collections.all[pageIdx]; + if (page.page.outputFileExtension === "html") { + // Only include HTML content into our Search Index File + const obj = { + url: page.url, + title: page.data.title, + body: page.content + }; + str += `${JSON.stringify(obj)}\n`; + } + } + + return str; + } +}