<commit_before>{% assign page_parts = page.url | remove_first: '/' | split: '/' %}

<script>
  console.log('--- left nav ---');
  console.log('page_parts: {{ page_parts }}');
  console.log('----')
</script>

{% assign pages = site.pages | sort:"url" %}
{% assign last_container = '' %}

<ul class="list-group sidebar-nav-v1" id="sidebar-nav">
{% for node in pages %}
    {% assign node_parts = node.url | remove_first: '/' | split: '/'  %}
    <!-- top level filter to only grab nodes that are under the same top-level path segment -->
    {% if node_parts[0] == page_parts[0] %}
        {% assign node_depth = node_parts | size %}
        {% if node_depth > 2 %}
            {% assign node_category = node_parts[1] %}
        {% else %}
            {% assign node_category = null %}
        {% endif %}

        <!-- open sub-list if:
            * previous_node doesn't exist and node_depth > 2
            * previous_node_depth <= 2 and node_depth > 2
            * previous_node_category != node_category -->
        {% if previous_node == null and node_depth > 2 %}
            {% assign sub_open = true %}
        {% elsif previous_node_depth <= 2 and node_depth > 2 %}
            {% assign sub_open = true %}
        {% elsif previous_node_category != node_category %}
            {% assign sub_open = true %}
        {% else %}
            {% assign sub_open = false %}
        {% endif %}

        <!-- close sub list if 
            * node_category != previous_node_category -->
        {% if node_category == null or previous_node_category == null %}
            {% assign sub_close = false %}
        {% elsif node_category != previous_node_category %}
            {% assign sub_close = true %}
        {% else %}
            {% assign sub_close = false %}
        {% endif %}

<script>
if({{ sub_close }})
    console.log('close category: {{ previous_node_category }}');    // note that you're closing the previous category
if({{ sub_open }})
    console.log('open category: {{ node_category }}');
console.log('   node: {{ node.url }}; depth: {{ node_depth }}; category: {{ node_category }}');
console.log('   previous node: {{ previous_node.url }}; depth: {{ previous_node_depth }}; category: {{ previous_node_category }}');
</script>

        {% assign previous_node = node %}
        {% assign previous_node_depth = node_depth %}
        {% assign previous_node_category = node_category %}


    {% endif %}
{% endfor %}

<!-- close the last category if node_category is not null -->
{% if previous_node_category != null %}
<script>
    console.log('close category: {{ previous_node_category }}');
</script>
{% endif %}

<script>
  console.log('--- end left nav ---')
</script>


</ul>
<commit_msg>left navigation markup generation rough in; still need to handle the case of index pages<commit_after>{% assign page_parts = page.url | remove_first: '/' | split: '/' %}

<script>
  console.log('--- left nav ---');
  console.log('page_parts: {{ page_parts }}');
  console.log('----')
</script>

{% assign pages = site.pages | sort:"url" %}
{% assign last_container = '' %}

<ul class="list-group sidebar-nav-v1" id="sidebar-nav">
{% for node in pages %}
    {% assign node_parts = node.url | remove_first: '/' | split: '/'  %}
    {% if node_parts[0] == page_parts[0] %}
        {% assign node_depth = node_parts | size %}
        {% if node_depth > 2 %}
            {% assign node_category = node_parts[1] %}
        {% else %}
            {% assign node_category = null %}
        {% endif %}

        <!-- open sub-list if:
            * previous_node doesn't exist and node_depth > 2
            * previous_node_depth <= 2 and node_depth > 2
            * previous_node_category != node_category -->
        {% if previous_node == null and node_depth > 2 %}
            {% assign sub_open = true %}
        {% elsif previous_node_depth <= 2 and node_depth > 2 %}
            {% assign sub_open = true %}
        {% elsif previous_node_category != node_category and node_category != null %}
            {% assign sub_open = true %}
        {% else %}
            {% assign sub_open = false %}
        {% endif %}

        <!-- close sub list if 
            * node_category != previous_node_category -->
        {% if previous_node == null %}
            {% assign sub_close = false %}
        {% elsif node_category != previous_node_category %}
            {% assign sub_close = true %}
        {% else %}
            {% assign sub_close = false %}
        {% endif %}

{% if sub_close == true %}
    <script>
    console.log('close category: {{ previous_node_category }}');    // note that you're closing the previous category
    </script>
        </ul>
    </li>
{% endif %}

{% if sub_open == true %}
    <script>
    console.log('open category: {{ node_category }}');
    console.log('   node: {{ node.url }}; depth: {{ node_depth }}; category: {{ node_category }}');
    console.log('   previous node: {{ previous_node.url }}; depth: {{ previous_node_depth }}; category: {{ previous_node_category }}');
    </script>

    <li class="list-group-item list-toggle">
        <a data-toggle="collapse" data-parent="#sidebar-nav" href="#collapse-{{ node_category }}">{{ node_category }}</a>
        <ul id="collapse-{{ node_category }}" class="collapse">
            <li>
                <a href="{{ site.baseurl }}{{ node.url }}">{{ node.title }}</a>
            </li>
{% else %}
    <script>
    console.log('   node: {{ node.url }}; depth: {{ node_depth }}; category: {{ node_category }}');
    console.log('   previous node: {{ previous_node.url }}; depth: {{ previous_node_depth }}; category: {{ previous_node_category }}');
    </script>

         <li>
            <a href="{{ site.baseurl }}{{ node.url }}">{{ node.title }}</a>
        </li>
{% endif %}




        {% assign previous_node = node %}
        {% assign previous_node_depth = node_depth %}
        {% assign previous_node_category = node_category %}


    {% endif %}
{% endfor %}

<!-- close the last category if node_category is not null -->
{% if previous_node_category != null %}
<script>
    console.log('close category: {{ previous_node_category }}');
</script>

        </ul>
    </li>
{% endif %}

<script>
  console.log('--- end left nav ---')
</script>


</ul>

{'fraction_non_alphanumeric': 0.1670659639035298, 'fraction_numerical': 0.003513815684395464, 'mean_word_length': 2.433114035087719, 'pattern_counts': {'":': 0, '<': 54, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1529900', 'n_tokens_mistral': 1986, 'n_tokens_neox': 1791, 'n_words': 471}