Skip to content

Latest commit

 

History

History
90 lines (78 loc) · 3.37 KB

search.md

File metadata and controls

90 lines (78 loc) · 3.37 KB
layout title
page
Search Tutorials
<script src="https://cdnjs.cloudflare.com/ajax/libs/lunr.js/2.3.9/lunr.min.js" integrity="sha512-4xUl/d6D6THrAnXAwGajXkoWaeMNwEKK4iNfq5DotEbLPAfk6FSxSP3ydNxqDgCw1c/0Z1Jg6L8h2j+++9BZmg==" crossorigin="anonymous"></script>
{% icon search %}
<script> var tutorials = { {% for topic in site.data %} {% if topic[1].type == 'use' or topic[1].type == 'admin-dev' or topic[1].type == 'basics' %} {% assign topic_material = site.pages | topic_filter:topic[0] %} {% assign topic_title = topic[1].title %} {% for tutorial in topic_material %} {% capture result_entry %}
{{ tutorial.title | escape }}
{{ topic_title}}

{{tutorial.description}}

{% if tutorial.tags %}

{% for tag in tutorial.tags %}

{{ tag }} {% endfor %}

{% endif %}

{% include _includes/contributor-badge-list.html contributors=tutorial.contributors %}

View Tutorial
{% endcapture %} "{{ tutorial.url }}": { "topic" : "{{ topic_title }}", "title" : "{{ tutorial.title | escape }}", "description": "{{ tutorial.description }}", "question" : "{{ tutoral.questions | join: ', '}}", "objectives" : "{{ tutorial.objectives | join: ', ' }}", "tags" : "{{ tutorial.tags | join: ', ' }}", "level" : "{{ tutorial.level }}", "time_estimation": "{{ tutorial.time_estimation }}", "url" : "{{ site.baseurl }}{{ tutorial.url }}", "level" : "{{ tutorial.level}}", "contributors": "{{ tutorial.contributors | join: ', '}}", "entry" : "{{ result_entry | strip_newlines | replace: '"',"'" }}" }{% unless forloop.last %},{% endunless %} {% endfor %} {% unless forloop.last %},{% endunless %} {% endif %} {% endfor %} }; function search(idx, q){ if(q.length > 2){ var results = idx.search(`*${q}*`).map(x => { return tutorials['/' + x.ref.replaceAll(".md", ".html")]; }).filter(x => x !== undefined); $("#results-container").html(results.map(x => x.entry)); } } fetch('{{ site.baseurl }}/search.json') .then(response => response.json()) .then(data => { var idx = lunr.Index.load(data); var params = (new URL(document.location)).searchParams; paramQuery = params.get('query'); if(paramQuery){ document.getElementById('search-input').value = paramQuery; search(idx, paramQuery); } $("#search-input").on("change keyup paste", function(){ search(idx, $("#search-input").val()); }) }); </script>