Catalog npm
Back to packageRELEASE DETAILS

0.0.1

npm

11ty.ts

An Eleventy wrapper for type supported configuration.

11tydeclarationsdefineconfigeleventytypestypescripttypingswrapper
Published19 Apr 2024
Direct dependencies3
Transitive dependenciesNot calculated

README

Current package documentation

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

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 3

Native requirements
3 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
chokidar
Environment
{
  "local_name": "chokidar",
  "alias": false,
  "peer_metadata": null
}
^3.6.0development
type-fest
Environment
{
  "local_name": "type-fest",
  "alias": false,
  "peer_metadata": null
}
^4.15.0development
@11ty/eleventy
Environment
{
  "local_name": "@11ty/eleventy",
  "alias": false,
  "peer_metadata": null
}
^2.0.1peer

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "402ab2e397592df6631680c0e56acf0663a53dc6",
  "tarball": "https://registry.npmjs.org/11ty.ts/-/11ty.ts-0.0.1.tgz",
  "fileCount": 6,
  "integrity": "sha512-kzGB7oiHuQNRGplN40/rcSSvmYL22jEri7azlMaBvAQpr3poDgBtKYtSaMXdyN5xnCEYHmba7kt6viG6C5RZjg==",
  "signatures": [
    {
      "sig": "MEUCIAjVTKD0fyKBu4Itm8xwn/w4pMuYWrfR0QjjhffRQObZAiEAoF34TJd0/ez3kp9zFe7xYqg73otusVlFu/OhBWH+5VU=",
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
    }
  ],
  "unpackedSize": 42548
}

Repository

PENDING
panoply/e11ty

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 18:06 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:fc007f876fef712bdee0bfcb06dd856d5534839f0031937f8bcfb686aa0db6e8

Other collected versions

0.0.72 Jan0.0.626 Jul0.0.59 Sept0.0.319 Apr0.0.219 AprView all collected versions →