mirror of
https://github.com/penpot/penpot.git
synced 2026-07-12 17:19:10 +00:00
- Convert .eleventy.js to eleventy.config.mjs (ESM) since @11ty/eleventy-plugin-rss@3.0.0 is ESM-only - Replace search-index.json.njk with search-index.json.11ty.js to avoid async templateContent access in Nunjucks filters - Update feed.njk to use new RSS plugin v3 filter names: rssLastUpdatedDate -> getNewestCollectionItemDate | dateToRfc3339 rssDate -> dateToRfc3339 - Add 11ty.js to templateFormats for search index generation
31 lines
684 B
JavaScript
31 lines
684 B
JavaScript
const elasticlunr = require("elasticlunr");
|
|
|
|
module.exports = {
|
|
permalink: "/search-index.json",
|
|
eleventyExcludeFromCollections: true,
|
|
eleventyComputed: {},
|
|
async data() {
|
|
return {
|
|
permalink: "/search-index.json",
|
|
eleventyExcludeFromCollections: true,
|
|
};
|
|
},
|
|
async render({ collections }) {
|
|
var index = elasticlunr(function () {
|
|
this.addField("title");
|
|
this.addField("content");
|
|
this.setRef("id");
|
|
});
|
|
|
|
collections.all.forEach((page) => {
|
|
index.addDoc({
|
|
id: page.url,
|
|
title: page.data.title,
|
|
content: page.templateContent,
|
|
});
|
|
});
|
|
|
|
return JSON.stringify(index.toJSON());
|
|
},
|
|
};
|