Speed up page build a bit

This commit is contained in:
Pk11 2021-11-01 22:28:58 -05:00
parent 4e3dc8c2cc
commit cb392f8fa0
3 changed files with 19 additions and 27 deletions

View File

@ -12,14 +12,7 @@
</a>
<br>
{% assign source = site.repo | append: "/blob/main/pages" %}
{% if page.collection == "en-US" %}
{% assign source = source | append: "/_en-US" | append: page.url | replace: ".html", ".md" %}
{% else %}
{% assign url = page.url | remove_first: "/" %}
{% assign source = source | append: "/_" | append: url | replace: ".html", ".md" %}
{% endif %}
{% assign source = source | %}
{% assign source = site.repo | append: "/blob/main/pages/" | append: page.path %}
{{ site.data[page.collection].strings.published-with | replace: "$1", source }}
</p>
</div>

View File

@ -37,19 +37,21 @@
</svg>
</button>
<ul class="dropdown-menu dropdown-menu-sm-end hover-content" id="language-dropdown">
{% assign ref = page.url | split: page.collection | last %}
{% for collection in site.collections %}
{% unless collection.label == "ic-IC" %}
{% for item in site[collection.label] %}
{% assign itemRef = item.url | split: item.lang | last %}
{% if itemRef == ref %}
<li><a class="dropdown-item{% if item.lang == page.collection %} active{% endif %}" lang="{{ item.lang }}" href="{{ item.url | remove: "index.html" | remove: ".html" }}" dir="{% if site.data.rtl contains item.collection %}rtl{%else%}ltr{% endif %}">{{ site.data.lang-names[item.lang] }}</a></li>
{% endif %}
{% endfor %}
{% assign path = page.path | replace: page.collection, collection.label %}
{% assign item = site[collection.label] | where: "path", path | first %}
{% if item %}
<li><a class="dropdown-item {% if item.lang == page.collection %}active{% endif %}" lang="{{ item.lang }}" href="{{ item.url | remove: "index.html" | remove: ".html" }}" dir="{% if site.data.rtl contains item.collection %}rtl{%else%}ltr{% endif %}">{{ site.data.lang-names[item.lang] }}</a></li>
{% endif %}
{% endunless %}
{% endfor %}
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="{% for item in site.ic-IC %}{% assign itemRef = item.url | split: item.collection | last %}{% if itemRef == ref %}{{ item.url | remove: ".html" }}{% endif %}{% endfor %}" accesskey="t">{{ site.data[page.collection].strings.translate-here }}</a></li>
{% assign path = page.path | replace: page.collection, "ic-IC" %}
{% assign item = site.ic-IC | where: "path", path | first %}
{% if item %}
<li><a class="dropdown-item" href="{{ item.url | remove: "index.html" | remove: ".html" }}" accesskey="t">{{ site.data[page.collection].strings.translate-here }}</a></li>
{% endif %}
<li><a class="dropdown-item" href="https://{% if site.data.crowdin-languages contains page.collection %}{{ site.data.crowdin-languages[page.collection] }}.{% endif %}crowdin.com/project/ds-homebrew-wiki" accesskey="c">{{ site.data[page.collection].strings.translate-on-crowdin }}</a></li>
</ul>
</div>

View File

@ -20,12 +20,11 @@ layout: compress
{% comment %} Get category list {% endcomment %}
{% assign items = site[page.collection] | where: "section", page.section | sort_natural: "title" %}
{% comment %} First do the index {% endcomment %}
{% for item in items %}
{% if item.url contains "index.html" %}
<a class="{% if page.title == item.title %}fw-bold{% endif %}" href="{{ item.url | remove: "index.html" }}">{{ item.title }}</a>
<hr class="mt-2 mb-2">
{% endif %}
{% endfor %}
{% assign item = items | where_exp: "item", "item.url contains 'index.html'" | first %}
{% if item %}
<a class="{% if page.title == item.title %}fw-bold{% endif %}" href="{{ item.url | remove: "index.html" }}">{{ item.title }}</a>
<hr class="mt-2 mb-2">
{% endif %}
<ul class="list-unstyled">
{% comment %} Then the pages not in categories {% endcomment %}
{% for item in items %}
@ -36,13 +35,11 @@ layout: compress
{% comment %} Finally, the other pages {% endcomment %}
{% for cat in site.data[page.collection].categories[page.section] %}
<li>
<details {% if page.category == cat.key or page.category.first and page.category contains cat %}open{% endif %}>
<details {% if page.category == cat.key %}open{% endif %}>
<summary>{{ cat.title }}</summary>
<ul>
{% for item in items %}
{% unless item.category == cat.key or item.category.first and item.category contains cat.key %}
{% continue %}
{% endunless %}
{% assign filtered = items | where: "category", cat.key %}
{% for item in filtered %}
<li class="{% if page.title == item.title %}fw-bold{% endif %}"><a href="{{ item.url | remove: ".html" }}">{{ item.title }}</a></li>
{% endfor %}
</ul>