diff --git a/pages/03.map/map.md b/pages/03.map/map.md new file mode 100644 index 0000000..af33e43 --- /dev/null +++ b/pages/03.map/map.md @@ -0,0 +1,4 @@ +--- +title: 'Trip Map' +template: map +--- diff --git a/themes/intotheeast/templates/map.html.twig b/themes/intotheeast/templates/map.html.twig new file mode 100644 index 0000000..0eaa901 --- /dev/null +++ b/themes/intotheeast/templates/map.html.twig @@ -0,0 +1,86 @@ +{% extends 'partials/base.html.twig' %} + +{% block content %} +{% set tracker_page = grav.pages.find('/tracker') %} +{% set all_entries = tracker_page ? tracker_page.children.published() : [] %} + +{% set map_entries = [] %} +{% for entry in all_entries %} + {% if entry.header.lat is not empty and entry.header.lng is not empty %} + {% set hero_url = null %} + {% if entry.header.hero_image and entry.media[entry.header.hero_image] is defined %} + {% set hero_url = entry.media[entry.header.hero_image].cropResize(240, 135).url %} + {% elseif entry.media.images|length > 0 %} + {% set hero_url = entry.media.images|first.cropResize(240, 135).url %} + {% endif %} + {% set map_entries = map_entries|merge([{ + 'lat': entry.header.lat|number_format(6, '.', ''), + 'lng': entry.header.lng|number_format(6, '.', ''), + 'title': entry.title, + 'date': entry.date|date('d M Y'), + 'url': entry.url, + 'hero': hero_url + }]) %} + {% endif %} +{% endfor %} + +
+ + + + + +{% endblock %} diff --git a/themes/intotheeast/templates/partials/base.html.twig b/themes/intotheeast/templates/partials/base.html.twig index c5d276e..0d3487c 100644 --- a/themes/intotheeast/templates/partials/base.html.twig +++ b/themes/intotheeast/templates/partials/base.html.twig @@ -6,11 +6,13 @@ {% if page.title %}{{ page.title }} | {% endif %}{{ site.title }} - +