11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
https://www.11ty.dev/
MIT License
16.89k stars 490 forks source link

The "path" argument must be of type string. Received type boolean (false) #2806

Open ryangittings opened 1 year ago

ryangittings commented 1 year ago

Operating system

macOS Ventura 13.0

Eleventy

2.0.0

Describe the bug

Original error stack trace: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type boolean (false)

at Template._write (/node_modules/@11ty/eleventy/src/Template.js:751:34)

Reproduction steps

  1. Use JS frontmatter as follows

    ---js
    {
    layout: "layouts/default.njk",
    pagination: {
    alias: "spage",
    data: "pages",
    size: 1,
    addAllPagesToCollections: true,
    },
    eleventyComputed: {
    title: (data) => data.spage.title,
    eleventyNavigation: {
      key: (data) => {
        if (data.spage.navigation) {
          return data.spage.navigation.key;
        }
    
        return null;
      },
      parent: (data) => {
        if (data.spage.navigation && data.spage.navigation.parent) {
          return data.spage.navigation.parent.navigation.key;
        }
    
        return null;
      }
    },
    permalink: (data) => {
      if (data.spage.slug) {
        return `${data.spage.slug.current}index.html`;
      }
    
      return false;
    }
    }
    }
    ---
  2. Run build

  3. Error

Expected behavior

To build pages that have a slug, and to ignore ones with a false permalink

Reproduction URL

No response

Screenshots

No response

zachleat commented 1 year ago

is this still relevant or was it fixed with https://github.com/11ty/eleventy/issues/2853

ryangittings commented 1 year ago

I believe this is still an issue. But I've worked around it. I think it happens when JS is used in the front matter for a permalink.

eaton commented 9 months ago

I'm running into this with Eleventy 2.0.1 with no serverless functionality in play: using pagination to iterate over an array in the global data, then a 'permalink' function in eleventyComputed.js, everything works fine unless I return FALSE to suppress output for one of the items.

Happy to whip up a bite-sized script to duplicate it if it helps, but it does seem to mirror just what this issue describes. Curious what your workaround was, @ryangittings?