@11ty/eleventy-data-transistor-fm 中文文档教程
Eleventy Data Plugin: Transistor.fm
API 文档:https://developers.transistor.fm/#episodes
Installation:
npm install @11ty/eleventy-data-transistor-fm
Usage
const TransistorFmPlugin = require("@11ty/eleventy-data-transistor-fm");
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(TransistorFmPlugin);
};
In a template
默认情况下,剧集存储在 transistorfm.episodes
中(这是可配置的)。
{% for episode in transistorfm.episodes %}
{{ episode.title }}
{% endfor %}
Use with an API key
默认情况下,晶体管 FM API 密钥是可选的。 如果你想使用一个,创建一个 .env
文件并为 TRANSISTOR_FM_API_KEY
添加一个条目:
TRANSISTOR_FM_API_KEY=This is my key
你可以使密钥成为必需的,甚至可以通过传递来更改环境变量的名称您的插件的选项。
Pass in options
const TransistorFmPlugin = require("@11ty/eleventy-data-transistor-fm");
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(TransistorFmPlugin, {
envApiKey: "TRANSISTOR_FM_API_KEY", // the name of the environment variable for the API key
envApiKeyRequired: false, // fail if the environment variable is missing?
data: "transistorfm.episodes", // where in Eleventy to store the return data
});
};
Eleventy Data Plugin: Transistor.fm
API Docs: https://developers.transistor.fm/#episodes
Installation:
npm install @11ty/eleventy-data-transistor-fm
Usage
const TransistorFmPlugin = require("@11ty/eleventy-data-transistor-fm");
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(TransistorFmPlugin);
};
In a template
By default, the episodes are stored in transistorfm.episodes
(this is configurable).
{% for episode in transistorfm.episodes %}
{{ episode.title }}
{% endfor %}
Use with an API key
By default, a Transistor FM API key is optional. If you want to use one, create a .env
file and add an entry for TRANSISTOR_FM_API_KEY
:
TRANSISTOR_FM_API_KEY=This is my key
You can make the key required or even change the name of the environment variable by passing options to your plugin.
Pass in options
const TransistorFmPlugin = require("@11ty/eleventy-data-transistor-fm");
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(TransistorFmPlugin, {
envApiKey: "TRANSISTOR_FM_API_KEY", // the name of the environment variable for the API key
envApiKeyRequired: false, // fail if the environment variable is missing?
data: "transistorfm.episodes", // where in Eleventy to store the return data
});
};