<!DOCTYPE html>
<html lang="en">
  <head>
    {% if page.path == "index.html" %}
    <title>{{ page.title }}</title>
    {% elsif page.title.size > 25 %}
    <title>{{ page.title }} - Quill</title>
    {% else %}
    <title>{{ page.title }} - Quill Rich Text Editor</title>
    {% endif %}
    {% include meta.html %}
    <link rel="stylesheet" href="/assets/css/base.css">
    {% assign sections = content | split: '<!-- head -->' %}
    {% for section in sections %}
      {% assign mod = forloop.index | modulo: 2 %}
      {% if mod == 0 %}
        {{ section | strip }}
      {% endif %}
    {% endfor %}
    <link rel="stylesheet" href="/assets/css/styles.css">
    {% include analytics.html  %}
  </head>
  <body{% if page.bodyClass != null %} class="{{ page.bodyClass }}"{% endif %}>
    {% include header.html %}
    {% assign heads = content | split: '<!-- head -->' %}
    {% for head in heads %}
      {% if forloop.last != true %}
        {% assign headMod = forloop.index | modulo: 2 %}
        {% if headMod == 1 %}
          {{ head | strip }}
        {% endif %}
      {% else %}
        {% assign scripts = head | split: '<!-- script -->' %}
        {% for script in scripts %}
          {% assign scriptMod = forloop.index | modulo: 2 %}
          {% if scriptMod == 1 %}
            {{ script | strip }}
          {% endif %}
        {% endfor %}
      {% endif %}
    {% endfor %}
    {% include footer.html %}
    <script src="//ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
    {% assign sections = content | split: '<!-- script -->' %}
    {% for section in sections %}
      {% assign mod = forloop.index | modulo: 2 %}
      {% if mod == 0 %}
        {{ section | strip }}
      {% endif %}
    {% endfor %}
    <script>
    $(document).ready(function() {
      $('.navbar-open').click(function() {
        $('.navbar-drop').addClass('active');
      });
      $('.navbar-close').click(function() {
        $('.navbar-drop').removeClass('active');
      });

      var counts = $('.github-count');
      if (counts.length > 0) {
        $.getJSON('https://api.github.com/search/repositories?q=quill+user:quilljs+repo:quill&sort=stars&order=desc', function(data) {
          if (data.items && data.items[0].full_name === 'quilljs/quill') {
            counts.text(data.items[0].stargazers_count.toLocaleString());
          }
        });
      }
    });
    </script>
  </body>
</html>
