Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. ---
  2. layout: null
  3. ---
  4.  
  5. {% capture tags %}
  6. {% for item in site.[[MY_COLLECTION]] %}
  7. {% for t in item.tags %}
  8. {{ t }}
  9. {% unless forloop.last %}^{% endunless %}
  10. {% endfor %}
  11. {% unless forloop.last %}^{% endunless %}
  12. {% endfor %}
  13. {% endcapture %}
  14.  
  15. {% assign tag_list = tags | strip | strip_newlines| split: "^" | uniq %}
  16.  
  17. {% capture links %}
  18. {% for item in site.[MY_COLLECTION] %}
  19. {% for tag in taglist %}
  20. {% for t in item.tags %}
  21. {% if t == tag %}
  22. {% capture link_temp %}
  23. {"source": {{ item.title | strip_newlines | jsonify }}, "target": {{ t | jsonify }}, "value": 1}^
  24. {% endcapture %}
  25. {% if link_temp != "" %}
  26. {{ links | append: link_temp }}
  27. {% endif %}
  28. {% assign link_temp = "" %}
  29. {% endif %}
  30. {% endfor %}
  31. {% endfor %}
  32. {% endfor %}
  33. {% endcapture %}
  34.  
  35. {% assign link_list = links | strip | split: "^" %}
  36.  
  37. {% capture my_json %}
  38. {
  39. "nodes": [
  40. {% for item in site.[MY_COLLECTION] %}
  41. { "id": {{ item.title | strip_newlines | jsonify }}},
  42. {% endfor %}
  43. {% for tag in tag_list %}
  44. { "id": {{ tag | jsonify }}}{% unless forloop.last %},{% endunless %}
  45. {% endfor %}
  46. ],
  47. "links": [
  48. {% for link in link_list %}
  49. {{ link | strip | strip_newlines }}{% unless forloop.last %},{% endunless %}
  50. {% endfor %}
  51. ]
  52. }
  53. {% endcapture %}
  54.  
  55. {{ my_json | strip }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement