Eleventy(11ty) logo Eleventy
The possum is Eleventy’s mascot
Eleventy 中文文档
Menu
Eleventy 5.81s
Remix 40.14s

插件是 Eleventy 可以从外部仓库导入到项目中的自定义代码。

官方插件列表 Jump to heading

所有官方插件都是用 @11ty 组织名,并且插件名称都包含 @11ty/ 前缀。

社区贡献的插件 Jump to heading

npm 上查看所有带有 eleventy-plugin 标签的软件包。以下列表是由社区添加到此网站的(没有排列顺序)。 你的插件也可以添加哦

安装插件 Jump to heading

利用 npm 安装插件。 Jump to heading

npm install @11ty/eleventy-plugin-rss --save

在配置文件中为 Eleventy 添加插件 Jump to heading

假设你的配置文件名为 .eleventy.js

Filename .eleventy.js
const pluginRss = require("@11ty/eleventy-plugin-rss");
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(pluginRss);
};

插件的配置参数 Jump to heading

addPlugin 函数设置第二个参数(可选)来自定义插件的行为。这一参数是特定于插件的。请查阅相应插件的文档 (例如,eleventy-plugin-syntaxhighlight 的 README 文件) 以了解其支持哪些参数。

const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(pluginSyntaxHighlight, {

// only install the markdown highlighter
templateFormats: ["md"],

init: function({ Prism }) {
// Add your own custom language to Prism!
}
});
};

为插件添加命名空间 Jump to heading

你可以利用 eleventyConfig.namespace 函数为部分配置分配命名空间。这将为所有过滤器(filters)、标签(tags)、助手(helpers)、快捷方式(shortcodes)、集合(collections)以及转换(transforms)添加前缀。

Filename .eleventy.js
const pluginRss = require("@11ty/eleventy-plugin-rss");
module.exports = function(eleventyConfig) {
eleventyConfig.namespace("myPrefix_", () => {
// the rssLastUpdatedDate filter is now myPrefix_rssLastUpdatedDate
eleventyConfig.addPlugin(pluginRss);
});
};
WARNING:
插件的命名空间是 Eleventy 赋予网站程序的功能,不能用在你自己创建的插件(配置)中。请查看 Issue #256

From the Community


Plugins: