-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.html
89 lines (89 loc) · 3.53 KB
/
search.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
layout: search
title: Search
permalink: /search/
---
<p class="max-w-5 mx-auto pt-0 sm:px-0 md:px-10 lg:px-16">Use the search bar to submit a query.</p>
<ul id="search-results" class="max-w-5 mx-auto pt-10 sm:px-0 md:pb-6 md:px-10 lg:px-16"></ul>
<script>
window.store = {
{% assign first_item = true %}
{% for post in site.posts %}
{% assign post_url = post.permalink | default: post.path %}
{% if post.title and post.description and post.title != '' and post.description != '' %}
{% unless first_item %}, {% endunless %}
{% assign first_item = false %}
"{{ post.path | slugify }}": {
"title": "{{ post.title | xml_escape }}",
"author": "Brandon Caples",
"category": "{{ post.category | xml_escape }}",
"description": {{ post.description | strip_html | strip_newlines | jsonify }},
"url": "{{ post_url | xml_escape }}",
"type": "{{ post.category | xml_escape }} Blog Post"
}
{% endif %}
{% endfor %}
{% for email in site.portfolio_email %}
{% unless first_item %}, {% endunless %}
"{{ email.url | slugify }}": {
"title": "Project: {{ email.title | xml_escape }}",
"author": "Brandon Caples",
"description": {{ email.description | strip_html | strip_newlines | jsonify }},
"img": "{{ email.featured_image.desktop_src }}",
"img_alt": "{{ email.featured_image.alt }}",
"url": "{{ email.permalink | xml_escape }}",
"type": "Email Project"
}
{% endfor %}
{% for web in site.portfolio_web %}
{% unless first_item %}, {% endunless %}
"{{ web.url | slugify }}": {
"title": "{{ web.title | xml_escape }}",
"author": "Brandon Caples",
"description": {{ web.description | strip_html | strip_newlines | jsonify }},
"img": "{{ web.featured_image.desktop_src }}",
"img_alt": "{{ web.featured_image.alt }}",
"url": "{{ web.permalink | xml_escape }}",
"type": "Web Project"
}
{% endfor %}
{% for tag in site.portfolio_tags %}
{% unless first_item %}, {% endunless %}
"{{ tag.formatted_tag | slugify }}": {
"title": "Projects tagged with “{{ tag.tag | xml_escape }}”",
"author": "Brandon Caples",
"description": {{ tag.description | strip_html | strip_newlines | jsonify }},
"url": "{{ tag.permalink | xml_escape }}",
"type": "Portfolio Tag"
}
{% endfor %}
{% for review in site.book_reviews %}
{% unless first_item %}, {% endunless %}
"{{ review.url | slugify }}": {
"title": "{{ review.book.title | xml_escape }}",
"author": {{ review.book.author | jsonify }},
"description": {{ review.description | strip_html | strip_newlines | jsonify }},
"img": "{{ review.featured_image.src }}",
"img_alt": "{{ review.featured_image.alt }}",
"url": "{{ review.permalink | xml_escape }}",
"type": "Book Review"
}
{% endfor %}
{% for page in site.pages %}
{% if page.title and page.description and page.title != '' and page.description != '' %}
{% unless first_item %}, {% endunless %}
{% assign page_url = page.permalink | default: page.path %}
"{{ page.url | slugify }}": {
"title": "{{ page.title | xml_escape }}",
"description": {{ page.description | strip_html | strip_newlines | jsonify }},
"url": "{{ page_url | xml_escape }}",
"type": "Page"
}
{% endif %}
{% endfor %}
};
function slugify(str) { return str.toLowerCase().trim().replace(/[^\w\s-]/g, '').replace(/\s+/g, '-').replace(/-+/g, '-') };
console.log(window.store);
</script>
<script src="{{ site.baseurl }}/assets/js/lunr.min.js"></script>
<script src="{{ site.baseurl }}/assets/js/search.js"></script>