0

I am currently using Jekyll to run a small site that lists events. I only want to show current and future events on my website. I am using Jekyll's blog posts to list events. A post represents an event.

What I want to do is add a line to the .md file that reads "published: false" when a post is past the current date. That way the post is automatically unpublished the day after the event is over.

I am able to list the events in the correct order (listed by event date) and get the site's current date. So I can write an IF statement to compare each event to the current date to see if it matches my question.

{% comment %}
    Displays all of the people from the _date2/ collection in a list. Also includes a link to post pages.
{% endcomment %}

<div class="container py-5">
  <div class="row">
    <div class="col-12">
      <h2>Special Events</h2>
      <hr class="m-0">
    </div>
  </div>

  <div class="row">
  {% assign currentDate = site.time %}
  {% assign sorted = (site.date2 | sort: 'event_date') %}
  {% for item in sorted %}
    {% if item.event_date >= currentDate %}
    <div class="col-12 mt-3">
      <div class="row d-flex align-items-center">
        <div class="pr-0 pt-2 px-sm-3 col-3 col-md-4">
          {% if item.banner_image and item.banner_image != "" %}
              <img alt="{{ item.title }}" src="{{ item.banner_image | absolute_url }}" class="img-fluid">
          {% else %}
              <img alt="{{ item.title }}" src="{{ '/img/placeholder.png' | absolute_url }}" class="img-fluid">
          {% endif %}
        </div>
        <div class="col-9 col-md-8">
          <h3 class="mb-0 mb-md-2">{{ item.event_date | date: "%A - %B %-d, %Y" }}</h3>
          <h4 class="mb-0 mb-md-2"><a href="{{ item.url | absolute_url }}">{{ item.title }}</a></h4>
          <p class="mb-0 mb-md-3">{{ item.sub_heading }}</p>
        </div>
      </div>
    </div>
    {% else %}

    Append "published: false" to file

    {% endif %}

  {% endfor %}
  </div>
</div>

I do not have any results yet but I am trying to read documentation to figure this out. I am hoping to hear from the community mainly because I feel I am asking the wrong questions on Google. Any direction on this will be greatly appreciated.

0 Answers0