Eleventy: addExtension produces filenames that include content

Created on 18 Aug 2020  路  7Comments  路  Source: 11ty/eleventy

Describe the bug
When adding a custom template format with addTemplateFormats and addExtension the result of the compile is added to the filename whenever a permalink property exists in front-matter:

To Reproduce
Steps to reproduce the behavior:

  1. Checkout this branch: https://github.com/MadeByMike/11ty-template-bug
  2. npm\yarn install
  3. npm run start

Important things to note:

  • Steps used to add custom template format are:
  eleventyConfig.addTemplateFormats("new");
  eleventyConfig.addExtension("new", {
    compile: () => () => "Test content - this gets included in the filename",
  });
  • Only seeing this bug where there is permalink value in the filename

Expected behavior
The filename for the page is derived from the permalink - not content.

Environment:

  • OS and Version: Win and Mac node 12
  • Eleventy Version 0.11.0
bug

Most helpful comment

@MadeByMike this is #1365!

All 7 comments

Resolved the cause - The mdx template and this example here ignore the input string and return content from the file-system (or a fixed string in this case) when the dynamic permalink setting is true. Because of the dynamic import MDX needs to resolve from the inputPath and not the string extracted by 11ty.

Best work-around for my needs that I can think of is to check if the string matches the file. I understand that we probably don't want to add additional context to these .compile functions as they follow the pattern of other template engines... maybe mdx's webpack requirements are special. I do wish I could avoid them entirely.

Sounds like this is the same issue? https://github.com/11ty/eleventy-plugin-vue/issues/6

Closing as duplicate of #1365

@MadeByMike this is #1365!

Reopening this until we know what鈥檚 going on 馃槄

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zachleat picture zachleat  路  3Comments

jamrelian picture jamrelian  路  3Comments

ndaidong picture ndaidong  路  4Comments

aaronstezycki picture aaronstezycki  路  3Comments

AjitZero picture AjitZero  路  3Comments