penpot/docs/search-index.json.11ty.js
Andrey Antukh 2defd5c155
⬆️ Upgrade docs/ dependencies and migrate to elevently v3 (#10242)
- 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
2026-06-17 17:37:20 +02:00

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());
},
};