@tkh/eleventy-plugin-rewriter

1.3.0 • Public • Published

@tkh/eleventy-plugin-rewriter

11ty filter to rewrite a permalink based on a files inputPath

Note: v1.0.0 is only tested with liquid templates.

Install

npm install @tkh/eleventy-plugin-rewriter

Usage

Add the filter to your .eleventy.js file.

const rewriter = {
  '/some/path': '/another/path',
}

module.exports = function(eleventyConfig) {
  // ...

  eleventyConfig.addFilter(
    'rewriter',
    require('@tkh/eleventy-plugin-rewriter')(rewriter)
  )

  // ...
}

Add a data file in the path you want to rewrite: /some/path/path.json

{
  "permalink": "{{ page.inputPath | rewriter }}"
}

The permalink for /some/path/index.md is now /another/path/index.html and eleventy will write the file to the same path in the output folder.

---
title: rewriter
---

The permalink for this page is /another/path/index.html

Package Sidebar

Install

npm i @tkh/eleventy-plugin-rewriter

Weekly Downloads

0

Version

1.3.0

License

MIT

Unpacked Size

4.45 kB

Total Files

6

Last publish

Collaborators

  • romain742
  • thierrywould