Skip to content
Discussion options

You must be logged in to vote

I have solved it now by just creating a custom collection that is just an object with all the data I need.

  eleventyConfig.addCollection('dataObject', function (collectionApi) {
  const data = {}
  const targetCollection = collectionApi.getFilteredByTag('tag')
  targetCollection.forEach((el) => {
    const id = el.data.id
    const metadata = el.data.metadata
    data[id] = {
      metadata,
    }
  })
  return data
})

then I can access it anywhere on my site via {{ collections.dataObject[id].metadata }}

Replies: 2 comments 2 replies

Comment options

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

pdehaan Aug 17, 2022
Collaborator

Comment options

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

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