11ty.ts

中文文档
0.0.7发布于 2026/01/02Apache-2.0TypeScriptESM + CJS零依赖近 30 天下载 2344

An Eleventy wrapper for type supported configuration.

原始使用文档
文档目录3 节
  1. Why?
  2. Example
  3. License

11ty.ts (Type Support)

Type support for Eleventy using defineConfig wrapper. This module can be dropped in to your .eleventy.js configuration file and will provide type support to the entire 11ty API, with JSDoc annotated descriptions and documentation linked references.

Why?

Type support is assumed nowadays and when modules don't provide this basic capability it makes life difficult and reflects poorly on otherwise good projects (like Eleventy). The team behind Eleventy have floated type support but seem hesitant and from my understanding were considering using JSDoc types (We live in a society, We are not animals). The last time I actively looked in the issues it was clear and rather apparent that those discussing type support or working on it were not very well versed on the subject (imo).

References

Install

The module requires @11ty/eleventy be installed along side it.

pnpm add 11ty.ts @11ty/eleventy -D

Usage

Pass it to the module.exports within a .eleventy.js or .eleventy.cjs configuration file.

const eleventy = require("11ty.ts");

module.exports = eleventy(function(eleventyConfig) {

  config.addPlugin()

  return {
    htmlTemplateEngine: 'liquid',
    passthroughFileCopy: false,
    pathPrefix: '',
    templateFormats: [
      'liquid',
      'json',
      'md',
      'css',
      'html',
      'yaml'
    ],
    dir: {
      input: 'site',
      output: 'public',
      includes: 'views/include',
      layouts: 'views/layouts',
      data: 'data'
    }
  }
});

In addition to the default export, you may optionally prefer to use the defineConfig named export:

const { defineConfig } = require('11ty.ts');

module.exports = defineConfig(eleventyConfig => {

  // {}

})

Auto-Typed Plugins

Eleventy plugins which provide typings within their distribution package will work if the syntactical structure of the plugin parameters apply options at index 1 of the argument order. The type utilities exposed in this module will convert the function parameters of plugins to a tuple and then reference the second argument, which is assumed to be the plugin options. It's far from an elegant approach, but due to the manner in which Eleventy digests plugins, this (for now) seems to be the only viable approach I've come up with.

Example

For the sake of brevity, let's assume you've installed a plugin from the NPM register called 11ty-plugin-example and this (fake) plugin has the following type declaration accompanied in the distribution package.

// Assuming the plugins uses this argument order
export function pluginName(eleventyConfig, options: {
  foo: string;
  bar: number;
  baz: boolean;
}) {

  // ...

}

This is rather typical and plugins which adhere to the above will be automatically typed. Using the eleventyConfig.addPlugin method will simply reference parameter options via tuple, so in your .eleventy.js file, completions will be applied when doing the following:

const { defineConfig } = require('11ty.ts');
const { pluginName } = require('11ty-plugin-example');

module.exports = defineConfig(eleventyConfig => {

  eleventyConfig.addPlugin(pluginName, {

    // Auto-typing will occur and intellisense completes
    // foo, bar and baz options.

  })

})

License

Apache 2.0

版本与发布记录

11ty.ts 共发布 6 个版本,首次发布于 2024/04/19;过去 12 个月发布了 1 个版本。

版本发布日期距今
0.0.7latest2026/01/0210 个月前
0.0.62025/07/261.3 年前
0.0.52024/09/092 年前
0.0.32024/04/202 年前
0.0.22024/04/202 年前
0.0.12024/04/192 年前

关于 11ty.ts 的常见问题

11ty.ts 是什么?

An Eleventy wrapper for type supported configuration.

如何安装 11ty.ts?

在项目目录运行 npm install 11ty.ts,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@11ty/eleventy(^3.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

11ty.ts 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

11ty.ts 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

11ty.ts 可以商用吗?

11ty.ts 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

11ty.ts 的下载量有多少?

根据 npm 官方下载统计,11ty.ts 在 2026/10/04 – 2026/11/02 这 30 天内被下载 2,344 次,日均约 78 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

11ty.ts 还在维护吗?

最新版本 0.0.7 发布于 2026/01/02(10 个月前);至今共发布 6 个版本,其中过去 12 个月发布了 1 个;首次发布于 2024/04/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。