{%- if request.stand_alone_mode == false and request.node and request.node.root.has_uri and request.namespace and request.namespace.powered_up %}
  <link rel="canonical" href="{{ request.node.root.uri.data }}" />
{%- endif %}

  <!-- this is needed for async javascript requests -->
  <script>var csrf_token = "{{ request.session.get_csrf_token() | default("none", true) }}";</script>

  <script src="/static/js/jquery-2.1.3.min.js"></script>
  <script src="/static/js/iframe-resizer/iframeResizer.contentWindow.min.js"></script>
  <script src="/static/js/custom.js"></script>
{%- if request.mode == "basic" and request.namespace and request.namespace.name == request.domain and request.namespace.google_analytics_id %}
  <script async src="https://www.googletagmanager.com/gtag/js?id={{ request.namespace.google_analytics_id }}"></script>
  <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', '{{ request.namespace.google_analytics_id }}');
  </script>
{%- endif %}
{% if request.namespace and request.namespace.mathjax %}
  <!-- references:
    * https://docs.mathjax.org/en/v2.7-latest/safe-mode.html
    * reference https://docs.mathjax.org/en/v2.7-latest/start.html#using-a-content-delivery-network-cdn
  -->
  <script type="text/javascript" async
    src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML,Safe">
  </script>
{%- endif %}
{%- include 'google-analytics.j2' %}
