GithubHelp home page GithubHelp logo

Comments (4)

dlitvakb avatar dlitvakb commented on July 28, 2024

Hey @flxsource,

Sadly, entry title is something one can't rely on as it's dependant on the Content Type structure.

But if you want to cherry-pick an entry you can do it like follows:

{% for entry in site.data.contentful.spaces.my_space.entry %}
  # By sys.id
  {% if entry.sys.id == 'MY_ENTRY_ID' %}
    # Do something...
  {% endif %}

  # By a property
  {% if entry.title == 'some fancy title' %}
    # Do something...
  {% endif %}
{% endfor %}

All entries provide a key for it's ID accessed with object.sys.id and you can easily filter by it, or you can filter by any property you want by directly accessing it.

Hope this helps

from jekyll-contentful-data-import.

flxsource avatar flxsource commented on July 28, 2024

I was hoping to avoid looping all of them, but it will certainly work.

Many thanks

from jekyll-contentful-data-import.

dlitvakb avatar dlitvakb commented on July 28, 2024

Sadly that's a limitation of the Liquid templating language, something like array.find { |object| object.sys.id == 'foo' } would have solved it.

Glad it helped! 👍

from jekyll-contentful-data-import.

flxsource avatar flxsource commented on July 28, 2024

I've found another workaround for this issue, as long as the data structure you have in contentful supports it. I've built a proof of concept (that's also sufficient for my use case), and if you think it's worth while I'll do some more work to put it behind a config option and add some error handling.

See #11

from jekyll-contentful-data-import.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.