Skip to content
Adds a meta-generator tag to the head of the generated html files
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
coverage
src
test
.codecov.yml
.gitignore
.nycrc
DCO.txt
LICENSE
README.md
index.js
package-lock.json
package.json

README.md

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

You can’t perform that action at this time.