Skip to content

Instantly share code, notes, and snippets.

@xupyprmv
Created January 20, 2016 11:51
Show Gist options
  • Select an option

  • Save xupyprmv/6540ee0ad741d21b9573 to your computer and use it in GitHub Desktop.

Select an option

Save xupyprmv/6540ee0ad741d21b9573 to your computer and use it in GitHub Desktop.

Revisions

  1. @kasperisager kasperisager revised this gist Mar 9, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions navigation.html
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    {% capture html %}
    <ul>
    {% if include.context == "/" %}
    <li class="{% if page.url == "/" %}active{% endif %}">
    @@ -20,3 +21,4 @@

    {% endfor %}
    </ul>
    {% endcapture %}{{ html | strip_newlines | replace:' ','' | replace:' ','' | replace:' ',' ' }}
  2. @kasperisager kasperisager revised this gist Mar 9, 2014. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions navigation.html
    Original file line number Diff line number Diff line change
    @@ -14,9 +14,7 @@
    {% if current == include.context %}
    <li class="{% if page.url contains entry.url %}active{% endif %}">
    <a href="{{ site.baseurl }}{{ entry.url }}">{{ entry.title }}</a>
    {% if entry.children != false %}
    {% include navigation.html context=entry.url %}
    {% endif %}
    {% include navigation.html context=entry.url %}
    </li>
    {% endif %}

  3. @kasperisager kasperisager revised this gist Mar 9, 2014. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion navigation.html
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,10 @@
    <ul>
    {% if include.context == "/" %}
    <li class="{% if page.url == "/" %}active{% endif %}">
    <a href="{{ site.baseurl }}/">{{ site.title }}</a>
    </li>
    {% endif %}

    {% assign entries = site.pages | sort: "path" %}
    {% for entry in entries %}

    @@ -16,4 +22,3 @@

    {% endfor %}
    </ul>

  4. @kasperisager kasperisager revised this gist Mar 8, 2014. 1 changed file with 0 additions and 21 deletions.
    21 changes: 0 additions & 21 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,21 +0,0 @@
    A simple nested page navigation list for Jekyll that highlights the currently active tree.

    #### Usage

    ```
    {% include navigation.html context="[top-level-path]" %}
    ```

    If you wanted to list all pages starting with the root, you'd do:

    ```
    {% include navigation.html context="/" %}
    ```

    If you instead wanted to list everything beneath `/foo/bar`, you'd do:

    ```
    {% include navigation.html context="/foo/bar/" %}
    ```

    To stop looking for children, and therefore avoid creating an empty `<ul>` if none exists, add `children: false` to your page's Front Matter.
  5. @kasperisager kasperisager revised this gist Mar 8, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion navigation.html
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    <ul>
    {% for entry in site.pages %}
    {% assign entries = site.pages | sort: "path" %}
    {% for entry in entries %}

    {% capture slug %}{{ entry.url | split: "/" | last }}{% endcapture %}
    {% capture current %}{{ entry.url | remove: slug | remove: "//" | append: "/" }}{% endcapture %}
  6. @kasperisager kasperisager revised this gist Mar 8, 2014. 1 changed file with 17 additions and 1 deletion.
    18 changes: 17 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,21 @@
    ### Usage
    A simple nested page navigation list for Jekyll that highlights the currently active tree.

    #### Usage

    ```
    {% include navigation.html context="[top-level-path]" %}
    ```

    If you wanted to list all pages starting with the root, you'd do:

    ```
    {% include navigation.html context="/" %}
    ```

    If you instead wanted to list everything beneath `/foo/bar`, you'd do:

    ```
    {% include navigation.html context="/foo/bar/" %}
    ```

    To stop looking for children, and therefore avoid creating an empty `<ul>` if none exists, add `children: false` to your page's Front Matter.
  7. @kasperisager kasperisager revised this gist Mar 8, 2014. 1 changed file with 6 additions and 3 deletions.
    9 changes: 6 additions & 3 deletions navigation.html
    Original file line number Diff line number Diff line change
    @@ -5,11 +5,14 @@
    {% capture current %}{{ entry.url | remove: slug | remove: "//" | append: "/" }}{% endcapture %}

    {% if current == include.context %}
    <li>
    <a href="{{ entry.url }}" class="{% if page.url == entry.url %}active{% endif %}">{{ entry.title }}</a>
    {% include navigation.html context=entry.url %}
    <li class="{% if page.url contains entry.url %}active{% endif %}">
    <a href="{{ site.baseurl }}{{ entry.url }}">{{ entry.title }}</a>
    {% if entry.children != false %}
    {% include navigation.html context=entry.url %}
    {% endif %}
    </li>
    {% endif %}

    {% endfor %}
    </ul>

  8. @kasperisager kasperisager revised this gist Mar 7, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion navigation.html
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@
    {% if current == include.context %}
    <li>
    <a href="{{ entry.url }}" class="{% if page.url == entry.url %}active{% endif %}">{{ entry.title }}</a>
    {% include categories.html context=entry.url %}
    {% include navigation.html context=entry.url %}
    </li>
    {% endif %}

  9. @kasperisager kasperisager revised this gist Mar 7, 2014. 1 changed file with 0 additions and 4 deletions.
    4 changes: 0 additions & 4 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,3 @@
    ```
    {% include navigation.html context="[top-level-path]" %}
    ```

    ### Todo

    - Fix list nesting
  10. @kasperisager kasperisager revised this gist Mar 7, 2014. 1 changed file with 11 additions and 11 deletions.
    22 changes: 11 additions & 11 deletions navigation.html
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,15 @@
    {% for entry in site.pages %}

    {% capture slug %}{{ entry.url | split: "/" | last }}{% endcapture %}
    {% capture current %}{{ entry.url | remove: slug | remove: "//" | append: "/" }}{% endcapture %}

    {% if current == include.context %}
    <ul>
    <ul>
    {% for entry in site.pages %}

    {% capture slug %}{{ entry.url | split: "/" | last }}{% endcapture %}
    {% capture current %}{{ entry.url | remove: slug | remove: "//" | append: "/" }}{% endcapture %}

    {% if current == include.context %}
    <li>
    <a href="{{ entry.url }}" class="{% if page.url == entry.url %}active{% endif %}">{{ entry.title }}</a>
    {% include categories.html context=entry.url %}
    </li>
    </ul>
    {% endif %}

    {% endfor %}
    {% endif %}

    {% endfor %}
    </ul>
  11. @kasperisager kasperisager revised this gist Mar 7, 2014. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,9 @@
    Usage: `{% include navigation.html context="[top-level-path]" %}`
    ### Usage

    ```
    {% include navigation.html context="[top-level-path]" %}
    ```

    ### Todo

    - Fix list nesting
  12. @kasperisager kasperisager revised this gist Mar 7, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    Usage: `{% include navigation.html context="[top-level-path]" %}`
  13. @kasperisager kasperisager created this gist Mar 7, 2014.
    15 changes: 15 additions & 0 deletions navigation.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    {% for entry in site.pages %}

    {% capture slug %}{{ entry.url | split: "/" | last }}{% endcapture %}
    {% capture current %}{{ entry.url | remove: slug | remove: "//" | append: "/" }}{% endcapture %}

    {% if current == include.context %}
    <ul>
    <li>
    <a href="{{ entry.url }}" class="{% if page.url == entry.url %}active{% endif %}">{{ entry.title }}</a>
    {% include categories.html context=entry.url %}
    </li>
    </ul>
    {% endif %}

    {% endfor %}