lemonstand / lscloud-theme-meyer

An eCommerce theme built using Angular for LemonStand.
MIT License
2 stars 1 forks source link

Blog json not rendering last comma correctly #312

Closed jennbrewer closed 6 years ago

jennbrewer commented 6 years ago

Blog API code rendering extra comma

{
  "blog": [

    {% for post in archives %}
    {% set isFirst = true %}
      {% if post.type is same as('blog') %}
        {
          "title": {{ post.title | json_encode() | raw }},
          "author": {
            "name": {{ post.author_name | json_encode() | raw }},
            "image": {{ profile_image.thumbnail(252, 'auto')|default('http://placehold.it/100x100') | json_encode() | raw }}
          },
          "thumbnail": {{ post.featured_image.thumbnail(1000, 'auto')|default('http://placehold.it/1000x365') | json_encode() | raw }},
          "permalink": {{ post.slug | json_encode() | raw }},
          "categories": [
            {% for category in post.categories %}
              {{ category.name | json_encode() | raw }}
              {% if not loop.last %},{% endif %}
            {% endfor %}
          ],
          "publish_date": {{ post.published_on |  date("m-d-Y") | json_encode() | raw }},
          "excerpt": {{ post.excerpt | unescape | json_encode() | raw }}
        }
        {% if isFirst %},{% set isFirst = false %}
        {% endif %}
      {% endif %}
    {% endfor %}
  ]
}

Testing in meyer-3 theme here:

https://meyer.lemonstand.com/backend/cms/theme

https://meyer.lemonstand.com/api/blog

https://meyer.lemonstand.com/backend/cms/theme/meyer-3/pages/page-api-blog

robotpony commented 6 years ago

Fixed in branch.