Skip to content
Discussion options

You must be logged in to vote

Your logic here looks right to me:

  eleventyConfig.addFilter('sortByTitle', values => {
      return values.slice().sort((a, b) => a.data.title.localeCompare(b.data.title))
  })

… but this error message seems to imply that one template might not have a title attribute (it seems to be undefined causing an error trying to then read undefined.localeCompare()):

"TypeError: Cannot read properties of undefined (reading 'localeCompare') (via Template render error)"

Replies: 1 comment 17 replies

Comment options

You must be logged in to vote
17 replies
@pdehaan
Comment options

pdehaan Sep 16, 2022
Collaborator

@Julianoe
Comment options

@pdehaan
Comment options

pdehaan Sep 16, 2022
Collaborator

@pdehaan
Comment options

pdehaan Sep 16, 2022
Collaborator

@Julianoe
Comment options

Answer selected by Julianoe
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