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
module.exports = () => {
return [
{
id: 1,
title: "An article n°1",
slug: "an-article-n-1",
body: "Writing an interesting article is hard."
},
{
id: 2,
title: "An article n°2",
slug: "an-article-n-2",
body: "Dogs, spiders and pythons are some examples of living beings."
},
{
id: 3,
title: "An article n°3",
slug: "an-article-n-3",
body: "Yesterday was Sunday. I believe today is a new Tuesday."
},
]
}
Update
I tried replacing "article.slug" with a function call that logs, and I can see it is called four times for each article -- once without article data.
slug An article n°1
slug An article n°2
slug An article n°3
slug null
slug An article n°1
slug An article n°1
slug Writing an interesting article is hard.
slug null
slug An article n°2
slug An article n°2
slug Dogs, spiders and pythons are some examples of living beings.
slug null
slug An article n°3
slug An article n°3
slug Yesterday was Sunday. I believe today is a new Tuesday.
In the front matter:
permalink: "/articles/{{ makeslug from = article.title }}/"
eleventyComputed:
title: "{{ article.title }}"
foo: "{{ makeslug from = article.body }}"
But when the slug is not rendered correctly there are less calls:
slug null
slug Writing an interesting article is hard.
slug null
slug An article n°2
slug An article n°2
slug Dogs, spiders and pythons are some examples of living beings.
slug null
slug An article n°3
slug An article n°3
slug Yesterday was Sunday. I believe today is a new Tuesday.
[11ty] Writing ./public/index.html from ./src/index.md (mi)
[11ty] Writing ./public/articles/{{ makeslug from = article.title }}/index.html from ./src/articles.mi (mi)
[11ty] Writing ./public/articles/an-article-n-2/index.html from ./src/articles.mi (mi)
[11ty] Writing ./public/articles/an-article-n-3/index.html from ./src/articles.mi (mi)
You can see the function was never called with the article title. I even replaced the template engine with a compile function that just logs, and again I can see times when the first article permalink is never rendered.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am not sure why that happens. Look for the slug "an-article-n-1" in these two updates:
My config:
And articles.mi:
And _data/cms.js:
Update
I tried replacing "article.slug" with a function call that logs, and I can see it is called four times for each article -- once without article data.
In the front matter:
But when the slug is not rendered correctly there are less calls:
You can see the function was never called with the article title. I even replaced the template engine with a compile function that just logs, and again I can see times when the first article permalink is never rendered.
The data in eleventyComputed doesn't seem to exhibit the same behaviour.
Beta Was this translation helpful? Give feedback.
All reactions