Skip to content

Commit 40f1bbd

Browse files
committed
Use JSON-LD link if found in HTML template
1 parent f794d67 commit 40f1bbd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pygeoapi/templates/_base.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
<a href="{{ link['href'] }}">{% trans %}json{% endtrans %}</a>
7676
{% elif link['rel'] == 'alternate' and link['type'] and link['type'] == 'application/ld+json' %}
7777
{% set links_found.jsonld = 1 %}
78+
{% set jsonld_href = link['href'] %}
7879
<a href="{{ link['href'] }}">{% trans %}jsonld{% endtrans %}</a>
7980
{% endif %}
8081
{% endfor %}
@@ -114,7 +115,11 @@
114115
<script>
115116
// Requests and embeds JSON-LD representation of current page
116117
var xhr = new XMLHttpRequest();
118+
{% if links_found.jsonld == 1 -%}
119+
var path = "{{ jsonld_href }}";
120+
{%- else -%}
117121
var path = window.location.protocol + "//" + window.location.host + window.location.pathname + "?f=jsonld";
122+
{%- endif %}
118123
xhr.open('GET', path);
119124
xhr.onload = function() {
120125
if (xhr.status === 200) {

0 commit comments

Comments
 (0)