我正在创建(希望创建)一个可以根据页面数据自动生成 Open Graph 图像的十一(11ty)插件。所以在模板中:
---
generate_og_image: true
image_text: "text which will be baked into the image"
og_image_filename: some_file_name.jpg
---
#some markdown
...
我可以.eleventy.js
使用以下插件通过插件处理文件中的每个文件:
module.exports = function (eleventyConfig) {
eleventyConfig.addLinter("og-image-generator", function(content, inputPath, outputPath) {
title = HOW_TO_ACCESS_TEMPLATE_FRONT_MATTER
createImage(title)
});
}
但只能访问模板的内容、inputPath 和 outputPath。
如何访问与模板关联的前沿数据?还是有更好的方法来解决这个问题?