1.3.0 • Published 6 years ago
@tkh/eleventy-plugin-rewriter v1.3.0
@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-rewriterUsage
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