Skip to content

Commit

Permalink
Add HTML site map
Browse files Browse the repository at this point in the history
  • Loading branch information
moisseev committed Apr 8, 2024
1 parent 325d2cd commit 75f5aa2
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 16 deletions.
39 changes: 23 additions & 16 deletions _includes/bottom.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
</div>
<!-- Site footer -->
<footer class="row-footer footer mt-auto px-3 py-2 z-0">
<!-- Social buttons -->
<div>
<a class="btn btn-xs btn-social-icon me-1 btn-primary" target="_blank" href="https://lists.rspamd.com/" data-bs-toggle="tooltip" data-bs-title="Mailing lists"><i class="fa-solid fa-envelope my-auto"></i></a>
<a class="btn btn-xs btn-social-icon me-1 btn-reddit" target="_blank" href="ircs://irc.oftc.net/rspamd" data-bs-toggle="tooltip" data-bs-title="#rspamd on OFTC">
<p style="font-size:80%">IRC</p>
</a>
<a class="btn btn-xs btn-social-icon me-1 btn-telegram" target="_blank" href="https://t.me/rspamd" data-bs-toggle="tooltip" data-bs-title="Telegram"><i class="fa-solid fa-paper-plane my-auto"></i></a>
<a class="btn btn-xs btn-social-icon me-1 btn-telegram" target="_blank" href="https://t.me/rspamd_ru" data-bs-toggle="tooltip" data-bs-title="Telegram RU">
<span class="fa-layers fa-fw my-auto">
<i class="fa-solid fa-paper-plane"></i>
<i class="fa-solid fa-star fa-flip-vertical" style="color: red" data-fa-transform="shrink-13 left-4"></i>
<i class="fa-solid fa-star fa-flip-vertical" style="color: red" data-fa-transform="shrink-13 right-4 down-4"></i>
</span>
</a>
<a class="btn btn-xs btn-social-icon me-1 btn-github" target="_blank" href="https://github.com/rspamd/rspamd" data-bs-toggle="tooltip" data-bs-title="GitHub"><i class="fa-brands fa-github my-auto"></i></a>
</div>
<div class="row">
<!-- Social buttons -->
<div class="col d-inline-flex">
<a class="btn btn-xs btn-social-icon me-1 btn-primary" target="_blank" href="https://lists.rspamd.com/" data-bs-toggle="tooltip" data-bs-title="Mailing lists"><i class="fa-solid fa-envelope my-auto"></i></a>
<a class="btn btn-xs btn-social-icon me-1 btn-reddit" target="_blank" href="ircs://irc.oftc.net/rspamd" data-bs-toggle="tooltip" data-bs-title="#rspamd on OFTC">
<p style="font-size:80%">IRC</p>
</a>
<a class="btn btn-xs btn-social-icon me-1 btn-telegram" target="_blank" href="https://t.me/rspamd" data-bs-toggle="tooltip" data-bs-title="Telegram"><i class="fa-solid fa-paper-plane my-auto"></i></a>
<a class="btn btn-xs btn-social-icon me-1 btn-telegram" target="_blank" href="https://t.me/rspamd_ru" data-bs-toggle="tooltip" data-bs-title="Telegram RU">
<span class="fa-layers fa-fw my-auto">
<i class="fa-solid fa-paper-plane"></i>
<i class="fa-solid fa-star fa-flip-vertical" style="color: red" data-fa-transform="shrink-13 left-4"></i>
<i class="fa-solid fa-star fa-flip-vertical" style="color: red" data-fa-transform="shrink-13 right-4 down-4"></i>
</span>
</a>
<a class="btn btn-xs btn-social-icon me-1 btn-github" target="_blank" href="https://github.com/rspamd/rspamd" data-bs-toggle="tooltip" data-bs-title="GitHub"><i class="fa-brands fa-github my-auto"></i></a>
</div>
<div class="col-auto d-inline-flex">
<a class="btn btn-xs btn-social-icon me-1 btn-primary" target="_blank" href="{{ site.baseurl }}/sitemap.html" data-bs-toggle="tooltip" data-bs-title="Site map"><i class="fa-solid fa-folder-tree my-auto"></i></a>
</div>
<div class="col d-inline-flex">
</div>
</div>
</footer>

<script src="https://code.jquery.com/jquery-3.7.1.min.js"
Expand Down
57 changes: 57 additions & 0 deletions _includes/directory-tree.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<ul>
{%- assign sorted_pages = include.pages | sort: "dir" -%}
{%- for page in sorted_pages -%}
{%- if page.layout == nil or page.layout == 'none' or page.dir contains '/blog/page' -%}
{%- continue -%}
{%- endif -%}
{% unless page.dir == prev_page_dir -%}
{%- assign path = page.dir | split: "/" -%}
{%- comment -%}
# Split returns [] for "/" but ["", "doc"] "/doc/" as removes empty strings.
{%- endcomment -%}
{%- unless path.size > 0 -%}
{%- assign path = path | push: "" -%}
{%- endunless -%}
{%- assign prev_path = prev_page_dir | split: "/" -%}
{%- unless prev_path.size > 0 -%}
{%- assign prev_path = prev_path | push: "" -%}
{%- endunless -%}
{%- assign levels_back = nil -%}
{%- assign levels_match = nil -%}
{%- for dir in prev_path -%}
{%- unless dir == path[forloop.index0] -%}
{%- assign levels_back = forloop.rindex -%}
{%- break -%}
{%- endunless -%}
{%- endfor -%}
{%- for dir in path -%}
{%- assign index0 = forloop.index0 -%}
{%- unless dir == prev_path[index0] -%}
{%- assign levels_match = index0 -%}
{%- break -%}
{%- endunless -%}
{%- endfor -%}
{%- for num in (1..levels_back) %}
</ul>
</li>
{%- endfor -%}
{% for dir in path offset:levels_match -%}
{%- assign dir_index_page = include.pages | where: "dir", page.dir | where: "name", "index.md" | first -%}
{%- unless dir_index_page -%}
{%- assign dir_index_page = include.pages | where: "dir", page.dir | where: "name", "index.html" | first -%}
{%- endunless %}
<li>
<a href="{{ site.baseurl }}{{ page.dir }}"><strong>{{ dir_index_page.title }}</strong></a>
<ul>
{%- endfor %}
{%- assign prev_page_dir = page.dir -%}
{%- endunless %}
{%- unless page.name == "index.md" or page.name == "index.html" %}
<li><a href="{{ site.baseurl }}{{ page.url }}">{{ page.title }}</a></li>
{%- endunless -%}
{% endfor -%}
{%- for dir in path %}
</ul>
</li>
{%- endfor %}
</ul>
3 changes: 3 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,6 @@ div#toc {
.btn-social-icon.btn-xs :first-child {
font-size: 1em;
}

.site-map h2 { font-size: 24px; }
.site-map > div > ul { padding-left: 1.5rem; }
40 changes: 40 additions & 0 deletions sitemap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
layout: support
title: Site map
---

# Site map

<div class="row site-map">
<div class="col-md">
<h2 class="mt-3">Pages</h2>

{% include directory-tree.html
pages=site.pages %}

</div>
<div class="col-md">
<h2 class="mt-3">Posts</h2>

<ul>
{%- for post in site.posts -%}
{%- assign date = post.date | split: " " | first -%}
{%- assign year = date | split: "-" | first -%}
{%- unless year == prev_year -%}
{%- unless prev_year == nil %}
</ul>
</li>
{%- endunless %}
<li>
<strong>{{ year }}</strong>
<ul>
{%- endunless %}
<li>{{ date }} <a href="{{ site.baseurl }}{{ post.url }}">{{ post.title }}</a></li>
{%- assign prev_year = year -%}
{%- endfor %}
</ul>
</li>
</ul>

</div>
</div>

0 comments on commit 75f5aa2

Please sign in to comment.