You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The docs show this example, under the "Permalink Function Using a Filter" section:
classTest{data(){return{title: "This is my blog post title",// Writes to "/this-is-my-blog-post-title/index.html"permalink: data=>`/${this.slug(data.key)}/`};}render(data){/* … */}}module.exports=Test;
But running this example yields an error:
> Having trouble rendering 11ty.js template ./index.11ty.js (TemplateContentRenderError)
> this.slug is not a function (TypeError):
TypeError: this.slug is not a function
It appears that filters are not actually available in a class's data method. They only seem to be available within the render method (this seems to be confirmed by console.logging this in both the data method and the render method, which logging yields different output).
(Incidentally, the example above's permalink key references data.key, but that should probably be data.title. I was going to submit a PR for that little fix, but thought the availability of filters on the data method deserved primacy.)
The text was updated successfully, but these errors were encountered:
The docs show this example, under the "Permalink Function Using a Filter" section:
But running this example yields an error:
It appears that filters are not actually available in a class's data method. They only seem to be available within the render method (this seems to be confirmed by console.logging
this
in both the data method and the render method, which logging yields different output).(Incidentally, the example above's permalink key references
data.key
, but that should probably bedata.title
. I was going to submit a PR for that little fix, but thought the availability of filters on the data method deserved primacy.)The text was updated successfully, but these errors were encountered: