eleventy-plugin-debug

A collection of debugging filters for Eleventy projects.

Usage no npm install needed!

<script type="module">
  import eleventyPluginDebug from 'https://cdn.skypack.dev/eleventy-plugin-debug';
</script>

README

eleventy-plugin-debug

INSTALLATION

npm install pdehaan/eleventy-plugin-debug

SETUP

// .eleventy.js
const debug = require("eleventy-plugin-debug");

module.exports = (eleventyConfig) => {
  eleventyConfig.addPlugin(debug);
  return {};
};

This plugin will add the following new global filters which will help with debugging:

  1. inspect — Wrapper for Node's native util.inspect() method.
  2. json — Wrapper for JavaScript's JSON.stringify() method. This filter takes one optional argument which is a string or number value to use for indentation, if you want pretty printed JSON objects.
  3. keys — Wrapper for JavaScript's Object.keys() method. This filter will also sort the returned array of key names for the specified object.

USAGE

Nunjucks

{{ collections.all | inspect }}
{{ page | json }}
{{ page | json(2) }}
{{ page | keys }}

LiquidJS

{{ collections.all | inspect }}
{{ page | json }}
{{ page | json: 2 }}
{{ page | keys }}

11ty.js

${ this.inspect(data.collections.all) }
${ this.json(data.page) }
${ this.json(data.page, 2) }
${ this.keys(data.page) }
${ this.json(this.keys(data.page), 2) }