Skip to content

Commit

Permalink
Use sections on sitemap page
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed Nov 24, 2023
1 parent ed0053e commit c512d94
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 27 deletions.
9 changes: 9 additions & 0 deletions _data/sections.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ blog:
breadcrumbs:
- title: Blog
url: /blog/
weight: 10

community:
title: Community
breadcrumbs:
- title: Community
url: /community/
nav: community
weight: 30

docs:
title: Documentation
breadcrumbs:
- title: Docs
weight: 20

events:
title: Events
Expand All @@ -28,16 +31,19 @@ events:
url: /community/
- title: Events
url: /events/
weight: 31

home:
title: Home
weight: 1

install:
title: Install
breadcrumbs:
- title: Docs
- title: Install
url: /install/
weight: 22

internal:
titel: Internal
Expand All @@ -49,17 +55,20 @@ learning:
breadcrumbs:
- title: Learning
url: /learning/
weight: 21

newsletter:
title: Newsletter
breadcrumbs:
- title: Newsletter
url: /newsletter/
weight: 32

releases:
title: Releases
breadcrumbs:
- title: Releases
url: /releases/
weight: 24

unspecified:
41 changes: 14 additions & 27 deletions _pages/sitemap.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@
section: internal
---
<section class="content">
<h2>Pages</h2>
<ul>
{% assign pages = site.pages | sort: "url" %}
{% for entry in pages %}
{% assign sections = site.data.sections | h_to_a | sort: "weight", "last" %}
{% for section in sections %}
<h2>{{ section.title | default: section.id }}</h2>
<ul>
{% assign entries = site.documents | where: "section", section.id %}
{% for entry in entries %}
{% if entry.collection == "posts" or entry.collection == "releases" %}
{% continue %}
{% endif %}
{% assign url = entry.url | prepend: "<code>" | append: "</code>" %}
{% assign path = entry.url | remove_first: "/" | split: "/" %}
<li>
{% for component in path -%}
{%- if forloop.last -%}
{%- unless forloop.first %}</code>{% endunless -%}
{%- continue -%}
{%- endif -%}
{%- if forloop.first %}<code>{% endif -%}
{{- component -}}/
{%- endfor %}
{% assign title = entry.title | default: entry.subtitle | default: url %}
{% if entry.redirect_to %}
{{ title }} → <a href="{{ entry.redirect_to }}" rel="nofollow">{{ entry.redirect_to }}</a>
Expand All @@ -29,21 +26,11 @@ <h2>Pages</h2>
{% if slug_title != path.last and down_title != path.last %}
(<code>{{ path.last }}</code>)
{% endif %}
{% unless entry.collection == "pages" %}
({{ entry.collection }})
{% endunless %}
</li>
{% endfor %}
</ul>
</ul>
{% endfor %}
</section>
{% assign collections = site.collections | where: "output", "true" %}
{% for collection in collections %}
{% if collection.label == "posts" or collection.label == "releases" or collection.label == "pages" %}
{% continue %}
{% endif %}
<section class="content">
<h2>{{ collection.label | capitalize }}</h2>
<ul>
{% for entry in collection.docs %}
<li><a href="{{ entry.url }}">{{ entry.title }}</a> {% if entry.date != site.time %}({{ entry.date | date: "%F" }}){% endif %}</li>
{% endfor %}
</ul>
</section>
{% endfor %}
15 changes: 15 additions & 0 deletions _plugins/h_to_a.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'jekyll'

module Jekyll
module HToA
def h_to_a(input, key = "id")
input.map do |k, v|
(v || {}).merge({
key => k
})
end
end
end
end

Liquid::Template.register_filter(Jekyll::HToA)

0 comments on commit c512d94

Please sign in to comment.