Skip to content

Commit 54e7b68

Browse files
committed
Return TBU image path in JSON API if its thumbnail not given yet
1 parent 2a4c218 commit 54e7b68

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

_includes/projects2json.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
{% capture default_thumbnail_path %}/assets/img/projects/{{ pj.year }}/{{ pj.id }}.webp{% endcapture %}
2+
{% capture default_thumbnail_exists %}{% file_exists default_thumbnail_path %}{% endcapture %}
13
[ {% for pj in projects %}
24
{
35
"id" : "{{ pj.id }}",
46
"title" : "{{ pj.title }}",
57
"description" : "{{ pj.description | escape }}",
6-
"thumbnail" : "{{ site.url }}/assets/img/projects/{{ pj.year }}/{% if pj.thumbnail %}{{ pj.thumbnail }}{% else %}{{ pj.id}}.webp{% endif %}",
8+
"thumbnail" : "{{ site.url }}/assets/img/projects/{{ pj.year }}/{% if pj.thumbnail %}{{ pj.thumbnail }}{% elsif default_thumbnail_exists %}../tbu.webp{% else %}{{ pj.id }}.webp{% endif %}",
79
"url" : "{{ site.url }}/projects/{{ pj.year }}/{{ pj.id }}",
810
"year" : "{{ pj.year }}",
911
"creators" : [

projects/search.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ layout: null
33
---
44

55
{% assign projects = site.data.projects %}
6+
{% capture default_thumbnail_path %}/assets/img/projects/{{ pj.year }}/{{ pj.id }}.webp{% endcapture %}
7+
{% capture default_thumbnail_exists %}{% file_exists default_thumbnail_path %}{% endcapture %}
68

79
[ {% for pj in projects %}
810
{
911
"title" : "{{ pj.title | escape }}",
1012
"description" : "{{ pj.description | strip_html | escape }}",
11-
"thumbnail" : "{{ site.url }}/assets/img/projects/{{ pj.year }}/{% if pj.thumbnail %}{{ pj.thumbnail }}{% else %}{{ pj.id}}.webp{% endif %}",
13+
"thumbnail" : "{{ site.url }}/assets/img/projects/{{ pj.year }}/{% if pj.thumbnail %}{{ pj.thumbnail }}{% elsif default_thumbnail_exists %}../tbu.webp{% else %}{{ pj.id }}.webp{% endif %}",
1214
"permalink" : "{{ site.url }}/projects/{{ pj.year }}/{{ pj.id }}",
1315
"year" : "{{ pj.year }}",
1416
"creators" : "{% for creator_id in pj.creator_ids %}{% assign creator = site.data.creators | find_exp: 'item', 'item.id == creator_id' %}{{ creator.name }}{% unless forloop.last %} / {% endunless %}{% endfor %}",

0 commit comments

Comments
 (0)