1
0

Search optimisation

This commit is contained in:
Emil Miler 2022-09-30 19:19:59 +02:00
parent ec9ffa07f9
commit 9d2305bd68
2 changed files with 3 additions and 8 deletions

View File

@ -1,18 +1,13 @@
function filter_name(str) function filter_name(str)
{ {
str = str.toLowerCase();
if (str.length == 0) { if (str.length == 0) {
for (let i = 0; i < articles.length; i++) { for (let i = 0; i < articles.length; i++) {
articles[i].style.display = "block"; articles[i].style.display = "block";
} }
} else { } else {
str = str.toLowerCase();
for (let i = 0; i < articles.length; i++) { for (let i = 0; i < articles.length; i++) {
let name = articles[i].getElementsByTagName("h2")[0].innerHTML.toLowerCase(); articles[i].style.display = !articles[i].dataset.title.includes(str) ? "none" : "block";
if (!name.includes(str)) {
articles[i].style.display = "none";
} else {
articles[i].style.display = "block";
}
} }
} }
} }

View File

@ -11,7 +11,7 @@
{% endmacro %} {% endmacro %}
{% macro print_article(page) %} {% macro print_article(page) %}
<article> <article data-title="{{ page.title | lower }}">
<h2><a href="{{ page.permalink }}">{{ page.title }}</a></h2> <h2><a href="{{ page.permalink }}">{{ page.title }}</a></h2>
<p>{{ page.summary | safe }}</p> <p>{{ page.summary | safe }}</p>
{{ self::page_info(page=page) }} {{ self::page_info(page=page) }}