<!--
  JS selector for site.
-->

{% if page.layout == 'home' or page.layout == 'post' %}
  {% if site.google_analytics.pv.enabled %}
    <!-- pv-report needs countup.js -->
    <script async src="https://cdn.jsdelivr.net/npm/countup.js@1.9.3/dist/countUp.min.js"></script>
    <script async src="{{ '/assets/js/dist/pvreport.min.js' | relative_url }}"></script>
  {% endif %}
{% endif %}

{% if page.layout == 'home'
    or page.layout == 'post'
    or page.layout == 'categories' %}
  {% assign type = page.layout %}
{% else %}
  {% assign type = "page" %}
{% endif %}

{% assign js = type | prepend: '/assets/js/dist/' | append: '.min.js' %}
<script defer src="{{ js | relative_url }}"></script>

{% if page.math %}
  <!-- MathJax -->
  <script defer src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
  <script defer src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
{% endif %}

{% if jekyll.environment == 'production' %}
  <!-- PWA -->
  <script defer src="{{ '/app.js' | relative_url }}"></script>

  <!-- GA -->
  {% if site.google_analytics.id %}
    {% include google-analytics.html %}
  {% endif %}

{% endif %}