madrilene / eleventy-excellent

Eleventy starter based on the workflow suggested by Andy Bell's buildexcellentwebsit.es.
https://eleventy-excellent.netlify.app/
Other
382 stars 69 forks source link

[Bug and fix] The build fails when using frontmatter permalink: false #54

Closed samimaat closed 1 month ago

samimaat commented 1 month ago

Firstly, thanks for the template!

I noticed when trying to implement a "draft mode" (11ty.dev) to the template that it doesn't build when the draft mode is on. I figured out that this is because the draft mode uses "permalink: false" in the mix.

This causes a build error with the helpers.js file in the getLinkActiveState function and in this part:

    if (itemUrl.length > 1 && pageUrl.indexOf(itemUrl.replace('/page-0/', '')) === 0) {
      response += 'data-state="active"';
    }

The error has to do with using pageUrl.indexOf on a permalink that doesn't exist or is set to false (I think). This can be fixed by using an if statement (or maybe something more elegant that I couldn't think of):

if (pageUrl === !false) {
}

Together like this:

  if (pageUrl === !false) {
    if (itemUrl.length > 1 && pageUrl.indexOf(itemUrl.replace('/sivu-0/', '')) === 0) {
      response += 'data-state="active"';
    }
  }
madrilene commented 1 month ago

Hi Sami!

Have you already implemented the changes I made to the helper.js file? --> https://github.com/madrilene/eleventy-excellent/commit/84b0ea9d9267f922bf57420dfe357da33198b6f4#diff-d53ac0fd6115f1597a83a9e8e5825dc425b8b0cf9db4c82be6c4dd7d0c23f3ad

samimaat commented 1 month ago

No, I haven't! Thanks. In this case the issue can be closed.