1.3.0 • Published 6 years ago

@tkh/eleventy-plugin-rewriter v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

@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
1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago