Skip to content

Computed data property returning empty - am I doing something wrong? #1625

Answered by pdehaan
philwolstenholme asked this question in Q&A
Discussion options

You must be logged in to vote

@philwolstenholme Maybe this?

module.exports = {
  noCssUrl: (data) => {
    if (data.page.filePathStem === "/index") {
      return `${data.page.filePathStem}.no-css.html`;
    }
    return `${data.page.filePathStem}/index.no-css.html`;
  },
  noJsUrl: (data) => {
    if (data.page.filePathStem === "/index") {
      return `${data.page.filePathStem}.no-js.html`;
    }
    return `${data.page.filePathStem}/index.no-js.html`;
  },
};

I noticed in https://www.11ty.dev/docs/data-computed/#real-world-example that they mention an "eleventyComputed.js global data file", but they don't include the nested eleventyComputed property in that example (you can search for "eleventyComputed.js" to jump …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@philwolstenholme
Comment options

Answer selected by philwolstenholme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants