Need private packages and team management tools?Check out npm Teams »

eleventy-plugin-meta-generator

0.1.3 • Public • Published

eleventy-plugin-meta-generator

CircleCI status Known Vulnerabilities codecov Greenkeeper badge

Adds a meta-generator tag to the head of the generated html files

Installation

That's simple!

npm install eleventy-plugin-meta-generator

Usage

Update your .eleventy.js like so:

// For liquid
const generator = require('eleventy-plugin-meta-generator');
 
module.exports = function (eleventyConfig) {
  eleventyConfig.addLiquidTag("generator", () => {
    return {
      render: function() {
        return generator()
      }
    };
  });
 
  return {
    templateFormats: [
      'liquid'
    ]
  };
};
const generator = require('eleventy-plugin-meta-generator');
 
module.exports = function (eleventyConfig) {
  eleventyConfig.addNunjucksTag("generator", (nunjucksEngine) => {
    return new function() {
      this.tags = ["generator"];
 
      this.parse = function(parser, nodes, lexer) {
        var tok = parser.nextToken();
 
        var args = parser.parseSignature(null, true);
        parser.advanceAfterBlockEnd(tok.value);
 
        return new nodes.CallExtensionAsync(this, "run", args);
      };
 
      this.run = function(_, myStringArg, callback) {
    generator()
      .then((metaTag) => {
        let ret = new nunjucksEngine.runtime.SafeString(metaTag);
        callback(null, ret);
      });
      };
    };
  });
 
  return {
    templateFormats: [
      'njk'
    ]
  };

Then you can use the new tag in your layout files:

<!-- liquid syntax -->
{% generator %}
<!-- nunjucks syntax -->
{% generator '' %}

License

MIT. See LICENSE

Install

npm i eleventy-plugin-meta-generator

DownloadsWeekly Downloads

1

Version

0.1.3

License

MIT

Unpacked Size

122 kB

Total Files

39

Last publish

Collaborators

  • avatar