11ty / 11ty-website

Documentation site for the Eleventy static site generator.

Home Page:https://www.11ty.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example of custom permalink in frontmatterdata broken on supplied data documentation

CanIGetaPR opened this issue · comments

https://github.com/11ty/11ty-website/blob/main/src/docs/data-eleventy-supplied.md#filepathstem--addedin-090-

---
permalink: "{{ page.filePathStem }}.html"
---

Yields:

[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] Unexpected token '.' (via SyntaxError)
[11ty]
[11ty] Original error stack trace: evalmachine.<anonymous>:1
[11ty] {{ page.filePathStem }}.html
[11ty]                        ^
[11ty]
[11ty] SyntaxError: Unexpected token '.'
[11ty]     at new Script (node:vm:100:7)
[11ty]     at createScript (node:vm:265:10)
[11ty]     at Object.runInNewContext (node:vm:306:10)

Using 11ty 2.0.1 and that's in a webc file.

fyi WebC requires WebC syntax in permalink

I can't figure out what WebC syntax is in yaml front matter data in general. Everything gets treated as a string instead of expanding variables.

I can try using js front matter data but the result is a failure because js front matter data does not get context including this, or page.

---js
{
    layout: "page-layout.webc",
    permalink: page.filePathStem + ".html"
}
---

I don't need to modify the permalink variable in front matter data for any reason anymore, but I'm a bit bothered that I couldn't figure out the equivalent of that example in webc.